I looked at this thread:
https://github.com/enyo/dropzone/issues/781
The issue is that it seems this would resize the original image and that would be the only image uploaded to the server?
I want to display the smaller version in my gallery to save bandwidth and the original when a user clicks on an image in the gallery to see it full size.
How could I upload both the smaller resized version and the original to my server?
(The images will be stored in a google cloud bucket when sent to my server and then queried from the cloud bucket on the client from there on)
Here's my current code which uploads the image to my server.
Dropzone.options.myAwesomeDropzone = {
autoProcessQueue: false,
paramName: "image",
acceptedFiles: 'image/*',
maxFilesize: 5, // MB
uploadMultiple: false,
maxFiles: 1,
init: function() {
var myDropzone = this;
url: '/upload'
this.on("addedfile", function() {
if (this.files[1] != null) {
this.removeFile(this.files[0]);
}
});
this.element.querySelector("button[type=submit]").addEventListener("click", function(e) {
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
this.on("success", function(response) {
localStorage.setItem("success_msg_local2", "Post Created. Reload Page");
window.location.href = "screenshots/index";
});
this.on('error', function(file, response) {
localStorage.setItem("error_msg_local", response);
window.location.href = "upload";
});
}
}
Dropzone doesn't really offer anything in regards to that. You can probably try to copy the file in the
addedfile
event, add some flag to it (myCopiedFile.isCopied = true;
) and add it again (withthis.addFile(copiedFile)
. Then you would need to make sure that the thumbnail isn't shown (by checking if the.isCopied
flag is set), and only resize it, if the flag is set or not.I agree with the point @robin-j made in the comment: this is something I would do on the server.
The advantages being: