Issue happens when I upload multiple files. Let's say I upload 7 files, some times it only takes 2 - other times all 7 files. I am not expecting any return yet, just using dropzone and move the file to the folder.
I reduced the code so its straight forward:
<form action="upload.php" class="dropzone" id="my-dropzone"
method="POST" enctype="multipart/form-data">
<span class="glyphicon glyphicon-picture"></span>
</form>
Javascript:
Dropzone.options.myDropzone = {
acceptedFiles: 'image/*',
maxFilesize: 25, // MB
addRemoveLinks: true,
init: function() {
var myDropzone = this;
this.on("success", function(file, dataURL) {
//No return yet, so ignore this
});
}
};
upload.php
$ds = DIRECTORY_SEPARATOR;
if (!file_exists("folder")) {
mkdir("../somefolder/", 0777, true);
}
$storeFolder = "../somefolder/";
if (!empty($_FILES)) {
$tempFile = $_FILES['file']['tmp_name'];
$targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;
$targetFile = $targetPath. $_FILES['file']['name'];
move_uploaded_file($tempFile,$targetFile);
}
Actually by default dropzone process 2 files on batches.
So if you try to upload 5 images it will send 3 ajax requests(2 files, 2 files, 1 file).
To send all 7 files at one request, you have to set parallelUploads option to the desired number - http://www.dropzonejs.com/#config-parallelUploads
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.