I'm running into an issue with the removedfile function in DropzoneJs. It seems to only delete the first file uploaded and there seems to be a problem with my renameFilename function.
Everything works smoothly if I don't rename the image, but I'd like each image to have a unique name. There appears to be an error when it comes to assigning a value to filename.
When I upload multiple images and try to delete them, only the first image gets deleted while the others remain. The "request" variable seems to retain 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;
}
});