Flask-Uploads IOError: [Errno 2] No such file or directory Flask-Uploads IOError: [Errno 2] No such file or directory flask flask

Flask-Uploads IOError: [Errno 2] No such file or directory


Both /tmp and /static/uploads/.., are absolute paths. And your code is looking in the / folder instead of looking in your project's folder. You should use the absolute path to point at your folder /path/to/your/project/static/uploads/.. or use a path relative to the code being executed such as ./static/uploads.

You can also use the following snippet to generate the absolute path:

from os.path import join, dirname, realpathUPLOADS_PATH = join(dirname(realpath(__file__)), 'static/uploads/..')


This worked for me:

basedir = os.path.abspath(os.path.dirname(__file__))file.save(os.path.join(basedir, app.config['UPLOAD_FOLDER'], filename))


@jidesakin's solutions works but here is another solution:

Move your uploads folder from static directory back to your project directory where your app folder is, the folder where your app and environment folders are.

Your structure will be like:

'projectfolder--/app      --config.py      --__init__.py------/static------/templates------config--uploads

Then change the content of you upload folder from 'static/uploads' to 'uploads' ...