jsはローカルから写真を選択することを実現する
5451 ワード
HTML:
jsコード:
背面ビューを選択:
OK、今日はまだ退勤していないので、気持ちが悪いので、かわいいとは言わないで、ふん
class="left-title"> URL:
type="text" class="url-text" placeholder=" URL " >
class="url-remarks"> : http:// https://
ビュー:
jsコード:
//
function checkImg(){
$("#checkImg").on('click',function () {
$("#upload").click(); // input:file ,
$("#upload").on("change",function(){
var objUrl = getObjectURL(this.files[0]) ; // ,
if (objUrl) {
$('#pic').show()
$("#pic").attr("src", objUrl) ; // src ,
}
});
});
}
// file url
function getObjectURL(file) {
var url = null ;
if (window.createObjectURL!=undefined) { // basic
url = window.createObjectURL(file) ;
} else if (window.URL!=undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file) ;
} else if (window.webkitURL!=undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file) ;
}
return url ;
}
背面ビューを選択:

OK、今日はまだ退勤していないので、気持ちが悪いので、かわいいとは言わないで、ふん