无法调用手机相机,选择文件后不能回显
//选择图片
$(function(){
var fil=$("#file");
$("").insertAfter("input");
fil.bind('change',function(){
var fordate=new FormData(); //得到一个FormData对象:
var fils=$("#file").get(0).files[0]; //得到file对象
console.log(fils);
fordate.append('pic',fils); //用append方法添加键值对
var srcc=window.URL.createObjectURL(fils); //传入的参数创建一个指向该参数对象的URL
console.log(srcc);
//检查img1是否为空
if(document.getElementById("img1").src==""){
$("#img1").attr({'src':srcc,'width':500+'px','heigth':500+'px'});
}else if(document.getElementById("img2").src==""){
$("#img2").attr({'src':srcc,'width':500+'px','heigth':500+'px'});
}else if(document.getElementById("img3").src==""){
$("#img3").attr({'src':srcc,'width':500+'px','heigth':500+'px'});
}else if(document.getElementById("img4").src==""){
$("#img4").attr({'src':srcc,'width':500+'px','heigth':500+'px'});
}else if(document.getElementById("img5").src==""){
$("#img5").attr({'src':srcc,'width':500+'px','heigth':500+'px'});
}else if(document.getElementById("img6").src==""){
$("#img6").attr({'src':srcc,'width':500+'px','heigth':500+'px'});
}else if(document.getElementById("img7").src==""){
$("#img7").attr({'src':srcc,'width':500+'px','heigth':500+'px'});
}else if(document.getElementById("img8").src==""){
$("#img8").attr({'src':srcc,'width':500+'px','heigth':500+'px'});
}else if(document.getElementById("img9").src==""){
$("#img9").attr({'src':srcc,'width':500+'px','heigth':500+'px'});
}
});
});