0
我试图上传大于900像素的图像。所以我确实上传时进行验证。当我们点击这个另一个文件按钮时,我会有加号。如何验证每次上传的图像大小
只有我得到的第一个输入框值。我无法获得其他文件。
<input type="file" id="upload_profile" class="upload_profile" name="upload_profile[]" />
脚本:
var _URL = window.URL || window.webkitURL;
$(".upload_profile").change(function(e) {
var file, img;
if ((file = this.files[0])) {
img = new Image();
img.onload = function() {
alert(this.width + " " + this.height);
};
img.onerror = function() {
alert("not a valid file: " + file.type);
};
img.src = _URL.createObjectURL(file);
}
});
使用'$(文件)。在( '变', '.upload_profile',函数(E){...});' – Phylogenesis
在你的代码的变量i没有定义(var file,img,i = 0;),如果我声明它,那么你的给定的代码工作正常。请使用提琴手了解更多http://fiddle.jshell.net/nzyu0q0q/ –
@Phylogenesis:它的工作..谢谢 – ammni