mardi 21 janvier 2020

Cannot Delete file if file renamed on Laravel

I have renamed my uploaded file on server, when i try to delete my image through dropzone.js the file does not get deleted because it is renamed.

var myDropzone = new Dropzone("div#dropzoneFileUpload", {
   addRemoveLinks: true, 
   url: baseUrl+"/img/upload/store",
   params: {
    _token: token,
   },
  success: function (data, textStatus, XmlHttpRequest){

  }, 

 removedfile: function(file) {

         var name = file.upload.filename;
                  jQuery.ajax({
                    headers: {
                      'X-CSRF-TOKEN': jQuery('meta[name="_token"]').attr('content')
                    },
                    type: 'POST',
                    url: '',
                    data: {filename: name},
                    success: function (data){
                      console.log("File has been successfully removed!!");
                    },
                    error: function(e) {
                      console.log(e);
                    }});
                  var fileRef;
                  return (fileRef = file.previewElement) != null ? 
                  fileRef.parentNode.removeChild(file.previewElement) : void 0;

 },

});


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire