
废话不说,直接上代码:
html代码,兼容移动端浏览器:
<input type="file" name="and_file_head" id="and_file_head" accept="image/*" capture="camera" style="display: none;"> <input type="file" name="file_head" id="file_head" accept="image/*" style="display: none;" />
js代码:
$("#file_head,#and_file_head").change(function(){
if(!allowFile(this.files[0], fileset)){
$("#file_head,#and_file_head").val(null); // 防止用户两次选择同一个文件
return;
}
var objUrl = getObjectURL(this.files[0]);
if (objUrl) {
$scope.validLocalids.push(objUrl);
$scope.$apply();
}
new ImageCompressor(this.files[0], compressOptions);
});
