Skip to content

Multiple File Upload and Server Side Validation #33

@skewwhiff

Description

@skewwhiff

Hi @greyli ,
Awesome plugin. I am using it to upload multiple files along with some server-side validation. Is there a way to return the individual status of each uploaded file? It is clear how to do it when only one file is being uploaded from https://github.com/greyli/flask-dropzone/blob/master/docs/advanced.rst#server-side-validation

Here's a barebones implementation of what works so far. I currently just append all error messages with the corresponding filename:

: : app.config['DROPZONE_UPLOAD_MULTIPLE'] = True app.config['DROPZONE_MAX_FILE_SIZE'] = 10 app.config['DROPZONE_MAX_FILES'] = 5 app.config['DROPZONE_UPLOAD_ON_CLICK'] = True : : @app.route('<upload_url>', methods=['GET', 'POST']) def file_upload(): if request.method=='POST': errors = [] for key, f in request.files.items(): if key.startswith('patent_file'): filename = secure_filename(f.filename) is_valid_file, msg, _, _ = validate_file(f, filename ) if not is_valid_file: errors.append(filename + ' has error: ' + msg) else: f.save(os.path.join(app.config['UPLOADED_PATH'], patent_filename)) if len(errors)>0: return ', '.join(errors), 400 return render_template('index.html')

This works. But it shows the same error message across all files. I am looking for a way to send individual status message per file. Is this achievable through the plugin? Thanks in advance.

Other details:

$ pip show flask_dropzone Name: Flask-Dropzone Version: 1.5.4 Summary: Upload file in Flask with Dropzone.js. Home-page: https://github.com/greyli/flask-dropzone Requires: Flask Required-by:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions