Uploading files using flask and mysqlab
Two ways of uploading files in Flask,
- Only directly into the folder
- Into database from the folder
Files are saved in database as binaries, so the uploaded file is converted to binary before upload and saved as a blob
in the database.
- Python
3.10.6
- **Clone **
https://github.com/pj8912/flask-file-upload.git
-
Create
virtual environment
and activate -
** Install requirements **
pip install requirements.txt
-
I used mysql for this project
-
Create an
.env
and add appropiate values for your mysql setup -
.env
variables :- DB_HOST=
- DB_USERNAME=
- DB_PWD=
- DB_NAME=file-test
Host, username, password and database name
My database name is file-test
- SQL file
Import sql file from
mysql/file-test.sql
python app.py