有这个代码: -
$('#myFile').bind('change', function() {
alert(this.files[0].type);
});
获取文件类型。这段代码: -
$('#myFile').bind('change', function() {
alert(this.files[0].size);
});
获取文件大小。但我找不到任何 jQuery API 来获取文件尺寸。请告诉我任何。任何帮助将不胜感激。提前致谢。
有这个代码: -
$('#myFile').bind('change', function() {
alert(this.files[0].type);
});
获取文件类型。这段代码: -
$('#myFile').bind('change', function() {
alert(this.files[0].size);
});
获取文件大小。但我找不到任何 jQuery API 来获取文件尺寸。请告诉我任何。任何帮助将不胜感激。提前致谢。
取自这里
这个答案已经发布在stackoverflow上,请看这里
尝试这个
var _URL = window.URL || window.webkitURL;
$("#myFile").change(function (e) {
var file, img;
if ((file = this.files[0])) {
img = new Image();
img.onload = function () {
alert(this.width + " " + this.height);
};
img.src = _URL.createObjectURL(file);
}
});
您可能希望让浏览器解码图像以获取尺寸:
<image>
DOM 对象,onload
事件处理程序