这很奇怪......
我可以使用dropzone发送0,1,2,3,4个文件,但不能发送5个或更多..
我想我在这里正确定义了选项:
source:{
{
title:"welcome page",
link:"/home"
},
{
title:"how it works",
link:"/howitworks"
},
...
}
我说得对,因为当我拖动超过6个文件时,我会看到错误消息:Dropzone.options.myDropzone = {
url: "action.php",
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 6,
maxFilesize: 5,
maxFiles: 6,
addRemoveLinks: true,
paramName: 'userfile',
acceptedFiles: 'image/*',
dictMaxFilesExceeded: 'Too many files! Maximum is {{maxFiles}}',
// The setting up of the dropzone
init: function() {
dzClosure = this; // Makes sure that 'this' is understood inside the functions below.
// for Dropzone to process the queue (instead of default form behavior):
document.getElementById("submit-form").addEventListener("click", function(e) {
e.preventDefault();
e.stopPropagation();
// Make sure that the form isn't actually being sent.
// If the user has selected at least one file, AJAX them over.
if (dzClosure.files.length !== 0) {
// dzClosure.options.autoProcessQueue = true;
dzClosure.processQueue();
// Else just submit the form and move on.
} else {
$('#foorm').submit();
}
});
// send all the form data along with the files:
this.on("sendingmultiple", function(data, xhr, formData) {
formData.append("name", $("#name").val());
formData.append("email", $("#email").val());
});
this.on("sucessmultiple", function(files, response) {
// dzClosure.options.autoProcessQueue = false;
$(location).attr('href', 'message_sent.html')
});
}
}
这个边界在源代码中是否有意义?
更多细节: 我的表格的简化版如下
Too many files! Maximum is 6
我的<form id="foorm" method="post" action="action.php" enctype="multipart/form-data">
<input type="text" id="name" name="name" required>
<input type="email" id="email" name="email" required>
<div class="dropzone" id="myDropzone">
<button type="submit" name="submit-form" id="submit-form">Send!</button>
</form>
首先显示action.php
和json_encode($_FILES);
并且在发送少于4个文件时它们是预期的,并且在发送5个或更多文件时json_encode($_POST);
修改
如果尺寸较小,我可以上传5个或更多!除了dropzone上的bug之外,这可能是什么? (诚实的问题)
答案 0 :(得分:1)
根据最近的评论,问题似乎是您受到PHP文件上传设置的限制。
在upload_max_filesize
中增加php.ini
。默认值为&#34; 2M&#34; (2MB)。
您可能还需要增加post_max_size
,其默认值为&#34; 8M&#34;。别忘了重启HTTP服务器。
答案 1 :(得分:0)
试试这个,将autoProcessQueue
设为true
,将init
设为this.on('addedfile', function(file) {
if (this.files[10] != null) {
this.removeFile(this.files[0]);
}
});
this.on('maxfilesreached', function(file) {
if (this.files[10] != null) {
this.removeFile(this.files[0]);
}
});
将以下事件添加到Dropzone.options.myDropzone = {
url: "action.php",
autoProcessQueue: true,
uploadMultiple: false,
parallelUploads: 10,
maxFilesize: 5,
maxFiles: 10,
addRemoveLinks: true,
method: 'put',
dictMaxFilesExceeded: 'Too many files! Maximum is {{maxFiles}}',
init: function() {
this.on('processing', function(file) {
data = file;
console.log(this.options.url);
});
this.on('addedfile', function(file) {
if (this.files[10] != null) {
this.removeFile(this.files[0]);
}
});
this.on('maxfilesreached', function(file) {
if (this.files[10] != null) {
this.removeFile(this.files[0]);
}
});
this.on('success', function(file, resp) {
if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) {
setTimeout(function () {
console.log('all are uploaded');
}, 500);
}
});
this.on("error", function(file, errorMessage, xhr) {
alert(file.name + ": " + errorMessage)
});
this.on("queuecomplete", function(file) {
alert("queuecomplete");
});
this.on("sending", function(file, xhr, formData) {
var _send = xhr.send;
xhr.send = function() {
_send.call(xhr, file);
}
});
}
}
以设置可以上传的内容
id -u
if[id -u == 1000];then
usermod -u 1000 www-data && groupmod -g 1000 www-data
elif[id -u == 500];then
usermod -u 500 www-data && groupmod -g 500 www-data
fi
答案 2 :(得分:-1)
只需将parallelUploads
参数设置为maxFiles
选项