I use dropzone.js for a nice upload form. I linked the php code to upload the files and i setted addRemoveLinks=true so i have the remove button.
I need an idea how
First off, you shouldn't simply overwrite the default removedfile
event handler, but rather register your own handler along with it.
You need to first get the ID back from the server (so you know how to relate to it) and then use this to setup the delete call.
Dropzone.options.myDropzone = {
init: function() {
this.on("success", function(file, response) {
file.serverId = response; // If you just return the ID when storing the file
// You can also return a JSON object then the line would
// look something like this:
//
// file.serverId = response.id;
//
// In that case make sure that you respond with the mime type
// application/json
});
this.on("removedfile", function(file) {
if (!file.serverId) { return; } // The file hasn't been uploaded
$.post("delete-file.php?id=" + file.serverId); // Send the file id along
});
}