style node dropzone div bootstrap php jquery drag-and-drop dropzone.js

php - div - dropzone node js



Dropzone.js eliminar el botón con php (1)

Yo uso dropzone.js para un buen formulario de carga. Conecté el código php para cargar los archivos y configuré addRemoveLinks = true, así que tengo el botón Eliminar.

Necesito una idea de cómo eliminar de manera efectiva el archivo cargado con un código php cuando presiono el botón Eliminar.

El php es simple de hacer, pero no necesito saber cómo relacionarlos. Ya intenté usar $ .post en esta función removedfile: function (file) pero no succes.

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


En primer lugar, no debe simplemente sobrescribir el controlador de eventos de removedfile predeterminado, sino registrar su propio controlador junto con él.

Primero debe recuperar la identificación del servidor (para que sepa cómo relacionarse con ella) y luego usar esto para configurar la llamada de eliminación.

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 }); }