我使用jquery文件上传插件来上传个人资料图片。
<input type="file" name="image" id="image" data-url="/users/profile/update/image">这是我的脚本
$(document).ready(function(){
$('#image').fileupload({
singleFileUploads : true,
acceptFileTypes : /(\.|\/)(gif|jpe?g|png)$/i,
maxFileSize : 10,
done: function(formContainer) {
console.debug("done");
}
});
});但是这个脚本允许提交任何类型的文件。有没有人可以帮助我,我的代码出了什么问题。我已经从插件文档中复制了正则表达式。https://github.com/blueimp/jQuery-File-Upload/wiki/Options
我在服务器端使用Spring3.2。
发布于 2013-12-03 21:16:14
我解决了这个问题,如果其他人需要的话,我正在写解决方案。
添加了以下脚本文件
jquery.fileupload-validate.js并添加了跟随脚本
$(document).ready(function){
$('#image').bind('fileuploadprocessfail', function (e, data) {
alert(data.files[data.index].error); //it will alert the message.
});
}); https://stackoverflow.com/questions/20351608
复制相似问题