helloflask/flask-dropzone

Pass filename to redirect_url

akent-q opened this issue · 2 comments

What's the best way to pass the uploaded filename(s) to the redirect url? e.g. something like:

{{ dropzone.config( redirect_url=url_for('view', file=filename) ) }}

You can't pass the filename like this since this function call will be rendered before the file was uploaded. Instead, you can store the filename in database or session in upload view, then get it back from the database or session:

from flask import session

@app.route('/upload')
def upload():
    # ...
    session['filename'] = the_filename

@app.route('/view')
def the_redirect_view():
    filename = session.get('filename)

Perfect. Thanks