Reputation: 21
Trying to upload files that are 3MB and greater with Dropzone, but it isn't working for me even though I specified a maxFilesize of 500MB. Tried looking at other answers but they didn't work for me.
Here is what I have for the HTML:
<form id="dropzone" action="photoupload.php" class="dropzone" enctype="multipart/form-data">
</form><br />
Here is what I have for the Javascript:
Dropzone.options.dropzone = {
maxFilesize: 500,
acceptedFiles: "image/*",
init: function() {
this.on("uploadprogress", function(file, progress) {
console.log("File progress", progress);
});
}
}
The script is working for the acceptedFiles part (rejecting all non-images), but won't upload files larger than 2 to 3 MB, and I'm clueless as to why.
Any help would be appreciated!
Upvotes: 2
Views: 14760
Reputation: 169
I think you need this:
Dropzone.prototype.accept = function(file, done) {
if (file.size > this.options.maxFilesize * 1024 * 1024 ) {
return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
} else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
return done(this.options.dictInvalidFileType);
} else if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) {
done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
return this.emit("maxfilesexceeded", file);
} else {
return this.options.accept.call(this, file, done);
}
};
Upvotes: 5
Reputation: 16726
Without further information I assume that the problem is related to your server. Obviously Dropzone can not control your server configuration, which often have filesize upload limitations as well.
In your case (PHP) the configuration options in question are upload_max_filesize
and post_max_size
. Please refer to the question "How to change the maximum upload file size in PHP?" for more information on how to change those options.
Upvotes: 3