For one of my current Flask projects i want to have a nice looking and easy to use file upload form.
That means no <input type="file"> form field where i have to select each file and the upload it on at a time.
I came across this nice tutorial for a HTML5/jquery file uploader, but the backend is written in PHP.
So I decided to try to get this working with Flask and it was easier as I supposed :-)
It’s important that paramname: 'file' in upload.js is equal to the key in app.py file = request.files['file']. Otherwise you will get a Error 400 Bad Request.
Also, the url parameter in upload.js has to be equal to the defined route in app.py.
When you drag&drop files to the dropzone, they will be saved in /uploads. I decided to replace the filename by the upload date, because otherwise the widespread IMG_XXX.JPG filenames possibly overwrite a already uploaded file.