的图片上传前图像的宽度和高度,我写了下面的HTML代码:如何检查上传
<input type="file" id="upload" class="im" onchange="fileSelectHandlerProfile('defaultProfile','true')" style="cursor:pointer"/>
当我们选择图像做,
这个代码将被解雇:
function fileSelectHandlerProfile(title, defalutProfile) {
var oFile;
oFile = $('#thumbUploadProfile')[0].files[0];
var rFilter = /^(image\/jpeg|image\/png|image\/gif|image\/bmp|image\/jpg|image\/pjpeg)$/i;
if (!rFilter.test(oFile.type)) {
$('.errorProfile').html('Please select a valid image file (jpg and png are allowed)').show();
}
}
我想检查文件的宽度和高度,怎么可能像oFile.type?
梅林回答您可以验证并且还使用jQuery的表单验证集成试试这个http://sgeek.org/validate-image-dimension-using-jquery/ – 2017-05-11 16:42:15