0
0
Flaskframework~5 mins

Saving uploaded files in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What Flask object is used to access uploaded files in a request?
The request.files object holds all uploaded files sent with the request.
Click to reveal answer
beginner
How do you save an uploaded file to a folder in Flask?
Use the save() method on the uploaded file object, passing the destination path as a string.
Click to reveal answer
intermediate
Why should you use secure_filename() when saving uploaded files?
It cleans the filename to prevent security risks like directory traversal or invalid characters.
Click to reveal answer
beginner
What Flask import is needed to use <code>secure_filename()</code>?
You import it from <code>werkzeug.utils</code> like this: <code>from werkzeug.utils import secure_filename</code>.
Click to reveal answer
beginner
What is a common folder to save uploaded files in a Flask app?
A folder like uploads/ inside your project directory is commonly used to store uploaded files.
Click to reveal answer
Which Flask object holds uploaded files from a form?
Arequest.data
Brequest.form
Crequest.files
Drequest.args
What method do you call to save an uploaded file in Flask?
Asave()
Bupload()
Cwrite()
Dstore()
Why use secure_filename() before saving a file?
ATo encrypt the file
BTo clean the filename for safety
CTo compress the file
DTo rename the file randomly
Where do you import secure_filename() from?
Awerkzeug.utils
Bflask.helpers
Cflask.utils
Dos.path
Which folder is commonly used to store uploaded files in Flask projects?
Astatic/
Btemplates/
Cconfig/
Duploads/
Explain the steps to save an uploaded file safely in a Flask app.
Think about how to get the file, make the name safe, and then save it.
You got /3 concepts.
    Why is it important to use secure_filename() when saving uploaded files?
    Consider what could happen if filenames are not cleaned.
    You got /3 concepts.