[英]jquery multiple file upload limit number of files not working
Jquery multiple file upload with ajax. 使用ajax上传Jquery多个文件。
option : {
limitMultiFileUploads : 3
}
is not working for jquery file upload. 不适用于jquery文件上传。
This is what i did : 这就是我做的:
$(function() {
$('#attachUpload').fileupload({
dataType: 'json',
limitConcurrentUploads: 1,
option:
{
maxFileSize: 40000,
maxNumberOfFiles: 2
},
start: function(e) {
$('.btn-sent').unbind('click'); // important - remove all event handlers
},
done: function(e, data) {
var data = $.parseJSON(data._response.jqXHR.responseText);
doneflag--;
if (doneflag == 0) {
$('#frmCompose').submit();
}
},
submit: function(e, data) {
data.formData = setFormData();
},
add: function(e, data) {
}
});
but filesize limit and number of files limit not working can anyone help please. 但文件大小限制和文件数限制不起作用,任何人都可以帮助请。
You are actually looking for maxNumberOfFiles
option. 您实际上正在寻找
maxNumberOfFiles
选项。
More details on the doc: https://github.com/blueimp/jQuery-File-Upload/wiki/Options 关于doc的更多细节: https : //github.com/blueimp/jQuery-File-Upload/wiki/Options
My working code: 我的工作代码:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: '../uploaderDemo/server/php/',
maxNumberOfFiles: 1,
acceptFileTypes: /(\.|\/)(mp3|wav)$/i
});
Get rid of the object with the name "option" and put the two settings at the same level as the rest of the options. 使用名称“option”删除对象,并将两个设置放在与其他选项相同的级别。
$(function() {
$('#attachUpload').fileupload({
dataType: 'json',
limitConcurrentUploads: 1,
maxFileSize: 40000,
maxNumberOfFiles: 2,
start: function(e) {
$('.btn-sent').unbind('click'); // important - remove all event handlers
},
done: function(e, data) {
var data = $.parseJSON(data._response.jqXHR.responseText);
doneflag--;
if (doneflag == 0) {
$('#frmCompose').submit();
}
},
submit: function(e, data) {
data.formData = setFormData();
},
add: function(e, data) {
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.