jquery - Dropzone.js remove button with php -


i use dropzone.js nice upload form. linked php code upload files , setted addremovelinks=true have remove button.

i need idea how efectivly delete filse uploaded php code when hit remove button.

the php simple need t know how relate them. tryed using $.post in function removedfile: function(file) no succes.

  removedfile: function(file) {     $.post("test.php");     var _ref;     return (_ref = file.previewelement) != null ? _ref.parentnode.removechild(file.previewelement) : void 0;  }, 

first off, shouldn't overwrite default removedfile event handler, rather register own handler along it.

you need first id server (so know how relate it) , use setup delete call.

dropzone.options.mydropzone = {   init: function() {     this.on("success", function(file, response) {       file.serverid = response; // if return id when storing file       // can return json object line       // this:       //       // file.serverid = response.id;       //       // in case make sure respond mime type       // application/json     });     this.on("removedfile", function(file) {       if (!file.serverid) { return; } // file hasn't been uploaded       $.post("delete-file.php?id=" + file.serverid); // send file id along     });   } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -