Skip to content
Advertisement

How to get multiple images from Flask request object at once in case of Content-Type:multipart/form-data?

I’m supposed to get multiple image files from the requests, but I can’t find a way to split a byte string request.files[key].read() properly to make np.ndarrays out of them.

Advertisement

Answer

files[key] gives only one object which has name=key in HTML, and .read() gives data only for this single file. So there is no need to split it.

If you have many files with name=key then you need files.getlist(key) to get list with all files and next use for-loop to read every file separatelly.

JavaScript

Minimal working example:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement