I'm using dropzone as a library to display uploaded images and upload new ones. Its default behavior is to sort the images from first to last, but I want to sort the images from last to first, I mean reverse the default order. this is my dropzone object:
myDropzone = new Dropzone("div#dropZone", {
clickable: "#mediaCenterInput",
paramName: "image",
dictDefaultMessage: "There is no images yet.",
url: "/resource",
maxFilesize: 10,
maxFiles: 1024,
parallelUploads: 1,
acceptedFiles: "image/*",
previewsContainer: "#dropZone",
previewTemplate: template,
});
in the event 'addedfile' i tried to reverse the order of files into 'myDropzone' object like that, but it doesn´t work;
myDropzone.on("addedfile", function (file) {
// some code ...
let myArray = myDropzone.files;
myArray.sort(function(a, b) {
return b.id - a.id;
});
myDropzone.files = myArray;
});
I've watched some question like:
Is there a way to do drag-and-drop re-ordering of the preview elements in a dropzone.js instance?
Dropzone.js Sortable files from server loaded files
But they don't work for me. Any idea?