I am using the removedfile function of DropzoneJs to delete the newly uploaded file, but it only deletes the first file, it has a problem with my renameFilename function.
Everything works fine if I don't rename the image, but I want the image not to have the same name. I definitely have an error when assigning the value to filename.
After uploading multiple images I press delete and it just deletes the first image, leaving the remaining images, "request" takes the name of the first photo.
Dropzone.autoDiscover = false;
var name;
var Dropzone = new Dropzone(".dropzone", {
maxFileSize: 50,
acceptedFiles: ".jpg,.png",
addRemoveLinks: true,
renameFilename: function (filename) {
name = new Date().getTime() + '-' + filename;
return name;
},
removedfile: function(file){
$.ajax({
type: 'POST',
url: route('product.images.remove'),
data:{
name: name
},
dataType: 'html'
});
var _ref;
return(_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
});