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?
✗ Incorrect
request.files contains uploaded files. request.form holds text form data.
What method do you call to save an uploaded file in Flask?
✗ Incorrect
The save() method saves the uploaded file to disk.
Why use
secure_filename() before saving a file?✗ Incorrect
secure_filename() cleans the filename to avoid security issues.
Where do you import
secure_filename() from?✗ Incorrect
It is imported from werkzeug.utils.
Which folder is commonly used to store uploaded files in Flask projects?
✗ Incorrect
uploads/ is a common folder for uploaded files.
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.