Complete the code to save an uploaded file in Flask.
file = request.files['file'] file.[1]('uploads/' + file.filename)
The save method stores the uploaded file to the given path.
Complete the code to check if the uploaded file has a filename before saving.
if file.[1] != '': file.save('uploads/' + file.filename)
The filename attribute holds the name of the uploaded file.
Fix the error in the code to securely save the uploaded file using Werkzeug's secure_filename.
from werkzeug.utils import [1] filename = secure_filename(file.filename) file.save('uploads/' + filename)
The correct import is secure_filename from werkzeug.utils.
Fill both blanks to save the uploaded file securely in a folder named 'uploads'.
from werkzeug.utils import [1] filename = [2](file.filename) file.save('uploads/' + filename)
Both blanks require secure_filename to import and use the function correctly.
Fill all three blanks to check if a file was uploaded, secure its filename, and save it.
if '[1]' in request.files: file = request.files['file'] if file.[2] != '': from werkzeug.utils import [3] filename = secure_filename(file.filename) file.save('uploads/' + filename)
The code checks if 'file' is in the uploaded files, then checks filename attribute, imports secure_filename, and saves the file securely.