Giter Club home page Giter Club logo

Comments (4)

greyli avatar greyli commented on June 17, 2024

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

from flask-dropzone.

greyli avatar greyli commented on June 17, 2024

Closing for inactive, please feel free to comment or reopen.

from flask-dropzone.

A-Shot avatar A-Shot commented on June 17, 2024

here is my code can any one let me know what I'm doing wrong?

index2.txt

from flask-dropzone.

CFGrote avatar CFGrote commented on June 17, 2024

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.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.