I'm having a similar issue. I've seen it recommended to use request.files.getlist("file[]") or request.files.getlist("file") << this worked for me for 2 files but when I started upload 3 separate files via 3 form elements I would only get 2. So here's the code I'm using right now.

for file in request.files:
    files[file].save(out_filename)
Answer from kkron on Stack Overflow
🌐
Miguel Grinberg
blog.miguelgrinberg.com › post › handling-file-uploads-with-flask
Handling File Uploads With Flask - miguelgrinberg.com
July 8, 2020 - Create a virtual environment and install Flask on it, then run the application with flask run. Every time you submit a file, the server will write a copy of it in the current directory.
Discussions

Request multiple files - New update old syntax does not work
There was an error while loading. Please reload this page More on github.com
🌐 github.com
3
December 6, 2018
Flask request.files.getlist unable to loop through multiple files
I would like to upload multiple files over api, I could get a list of 'FileStorage' when I print out f it looks like: [ , More on stackoverflow.com
🌐 stackoverflow.com
March 8, 2020
python - Get the data received in a Flask request - Stack Overflow
I want to be able to get the data sent to my Flask app. I've tried accessing request.data but it is an empty string. How do you access request data? from flask import request @app.route('/', meth... More on stackoverflow.com
🌐 stackoverflow.com
python - Flask - request.files.getlist() - do not skip empty - Stack Overflow
I have form with 4 file inputs and 4 text inputs Form image: HTML Code: More on stackoverflow.com
🌐 stackoverflow.com
February 4, 2019
🌐
Rip Tutorial
riptutorial.com › file uploads
Flask Tutorial => File Uploads
Learn Flask - request.files['name'] # single required filerequest.files.get('name') # None if not postedrequest.files.getlist('name') # list of zero or...
🌐
GitHub
github.com › pallets › flask › issues › 3016
Request multiple files - New update old syntax does not work · Issue #3016 · pallets/flask
December 6, 2018 - ob = request.files.getlist("MultipleFileUpload") ob = request.files.to_dict() None of them works · It just upload 1 file or none · Python version: 2.7.12 64-bit · Flask version: 1.0.2 · Werkzeug version: 0.14.1 · No one assigned · No labels · No labels ·
Author   DanielKrsek
🌐
Rip Tutorial
riptutorial.com › save uploads on the server
Flask Tutorial => Save uploads on the server
request.files['profile'] # single file (even if multiple were sent) request.files.getlist('charts') # list of files (even if one was sent)
Find elsewhere
🌐
ProgramCreek
programcreek.com › python › example › 51528 › flask.request.files
Python Examples of flask.request.files
def whitelist_add(): log.info("whitelist_add called") try: file_ = request.files["file"] handle, filename = tempfile.mkstemp() os.close(handle) file_.save(filename) data = request.get_json() if data and "functions" in data: functions = data["functions"] else: functions = None bass.whitelist_add(filename, functions) os.unlink(filename) except KeyError: log.exception("") return make_response(jsonify(message = "Sample file 'file' missing in POST request"), 400) return jsonify(message = "OK")
🌐
Sourcecodequery
sourcecodequery.com › example-method › flask.request.files.getlist
SourceCodeQuery - Python flask.request.files.getlist Examples
def result(): uploaded_files = flask.request.files.getlist("files") pathes = list() for file in uploaded_files: filename = (file.filename) path = os.path.join(app.config['UPLOAD_FOLDER'], filename) file.save(path) pathes.append(path) data = prepare_images(config,pathes) captions , scores = model.test(sess, data, vocabulary) result = { 'captions' : captions , 'scores' : scores } return jsonify(result)
Top answer
1 of 16
2247

The docs describe the attributes available on the request object (from flask import request) during a request. In most common cases request.data will be empty because it's used as a fallback:

request.data Contains the incoming request data as string in case it came with a mimetype Flask does not handle.

  • request.args: the key/value pairs in the URL query string
  • request.form: the key/value pairs in the body, from a HTML post form, or JavaScript request that isn't JSON encoded
  • request.files: the files in the body, which Flask keeps separate from form. HTML forms must use enctype=multipart/form-data or files will not be uploaded.
  • request.values: combined args and form, preferring args if keys overlap
  • request.json: parsed JSON data. The request must have the application/json content type, or use request.get_json(force=True) to ignore the content type.

All of these are MultiDict instances (except for json). You can access values using:

  • request.form['name']: use indexing if you know the key exists
  • request.form.get('name'): use get if the key might not exist
  • request.form.getlist('name'): use getlist if the key is sent multiple times and you want a list of values. get only returns the first value.
2 of 16
320

For URL query parameters, use request.args.

search = request.args.get("search")
page = request.args.get("page")

For posted form input, use request.form.

email = request.form.get('email')
password = request.form.get('password')

For JSON posted with content type application/json, use request.get_json().

data = request.get_json()
🌐
Stack Overflow
stackoverflow.com › questions › 54514120 › flask-request-files-getlist-do-not-skip-empty
python - Flask - request.files.getlist() - do not skip empty - Stack Overflow
February 4, 2019 - The bottom line: GetFiles has 3 elements (because only 3 files were selected), Name has 4 elements. Python zip doc says: The iterator stops when the shortest input iterable is exhausted. You know which "Image" goes with which "Text", but the computer does not. One approach: in the html: give each Image input a unique name, something like name="Image-1". in the py: iterate over Names and "get" the image that goes with that name (something like request.files.get('Image-'+{index})
🌐
PythonAnywhere
pythonanywhere.com › forums › topic › 27885
Save text to file via requests POST, flask : Forums : PythonAnywhere
July 5, 2020 - Using Requests and Flask - don't want to go down the file upload function. ... @app.route('/postit2', methods=['GET', 'POST']) def postit2(): x = request.files.getlist('textfile') #gives empty dict: x = request.files.getlist('textfile') with open('/home/MadMartin/datapostfiles/EFL9.txt', 'w') as f: f.write(str(x)) return '''ok'''
🌐
LinuxTut
linuxtut.com › en › f036453df5f38aeffa03
Upload multiple files in Flask
November 22, 2016 - It was easy to specify multiple items on the client side and send them, but I was struggling because I was not sure how to receive them on the server side. .. .. As a result of various investigations, when multiple files are sent, it seems that they are stored in request.files with the same KEY, so it is solved by getting from request.files with "getlist ()" instead of "get ()".
🌐
BrowserStack
browserstack.com › home › guide › working with flask get requests: examples and best practices
Working with Flask GET Requests: Examples and Best Practices | BrowserStack
September 17, 2025 - Issue: Query parameters might appear multiple times, such as tag=python&tag=flask, which needs to be handled properly. Solution: Use request.args.getlist() to retrieve all values for a parameter. 5. Special Character Handling · Issue: Special characters (e.g., spaces or slashes) in query parameters can break URLs if not properly encoded.
🌐
GitHub
github.com › pallets › flask › issues › 3342
Using getlist for files is never empty? · Issue #3342 · pallets/flask
August 24, 2019 - pallets / flask Public · There was an error while loading. Please reload this page. Notifications · You must be signed in to change notification settings · Fork 16.4k · Star 69.6k · New issueCopy link · New issueCopy link · Closed · Closed · Using getlist for files is never empty?#3342 · Copy link · dzpt · opened · on Aug 24, 2019 · Issue body actions · I want to get file list from form by using: photos = request.files.getlist("photo") However if i haven't select anything, the photos value is never be [] like other fields.
🌐
GitHub
gist.github.com › liulixiang1988 › cc3093b2d8cced6dcf38
upload multiple files in Flask · GitHub
upload multiple files in Flask. GitHub Gist: instantly share code, notes, and snippets.
🌐
OneUptime
oneuptime.com › home › blog › how to handle file uploads in flask
How to Handle File Uploads in Flask
February 2, 2026 - Sometimes you need to accept multiple files in a single request. Flask handles this with the getlist() method.