Closed Sacchid closed 5 years ago
Sorry for taking so long. This feature is not implemented currently, but your can make it by yourself. First, register the event listeners with JavaScript:
Dropzone.options.myAwesomeDropzone = {
success: function(file, response) {
file.serverFileName = response.file_name; // pass filename
},
removedfile: function (file, data) { // triggered when remove file button was clicked
$.ajax({ // send AJAX request to Flask to remove file
type:'POST',
url:'/deletefile',
data : {"filename" : file.serverFileName}, // pass filename
success : function (data) {
alert('File removed from server.')
}
});
}
};
Then, create the view function to delete file with Flask:
@app.route('/deletefile')
def delete_file():
filename = request.form['filename']
file_path = os.path.join(your_upload_path, filename)
os.remove(file_path)
Not test yet, let me know if it works ;)
Closing for inactive, please feel free to comment or reopen.
i'm interested in this feature, too. any updates? where exactly am i supposed to paste the js snipped (copied from above)?
Dropzone.options.myAwesomeDropzone = {
success: function(file, response) {
file.serverFileName = response.file_name; // pass filename
},
removedfile: function (file, data) { // triggered when remove file button was clicked
$.ajax({ // send AJAX request to Flask to remove file
type:'POST',
url:'/deletefile',
data : {"filename" : file.serverFileName}, // pass filename
success : function (data) {
alert('File removed from server.')
}
});
}
};
From flask-dropzone/examples/custom-option, whenever remove button is pressed, image (file) is removed from web-view but not from uploads folder. How to check which image is removed by clicking on button & how to remove it from uploads? And can I temp. save files for session & then based some logic decide to delete them or save permanently.