From the course: Flask Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
File uploads from users
- [Narrator] Our URL shortener right now allows people to provide a short name for a URL that they want to get to quickly. But remember, our URL shortener not only takes URLs, but also can take files for users that they can then upload, and have a short name to get to quickly. So in order to accept files, we have to add a new form to our home page to be able to accept that. So let's go ahead and move back to our home dot html. And we want to create a form very similar to the one that we have. So let's go ahead and copy that, and down below paste, and now there's a few changes we're going to have to make to this second form. So in the top form tag here on our second form, we're going to add an extra field here called enctype, and make sure that it's set to multi-part slash form data. Essentially what this says is that this form is allowed to have file uploads. Next we're going to change this from website URL to simply…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Using redirect and url_for for error handling3m 41s
-
(Locked)
Saving to a JSON file5m 6s
-
(Locked)
Parsing a JSON file for conflicting entries3m 11s
-
(Locked)
Alerting users with message flashing5m 26s
-
(Locked)
File uploads from users8m 17s
-
(Locked)
Variable rules in URLs5m 39s
-
(Locked)
Working with static files4m 19s
-
(Locked)
Displaying custom error pages5m 49s
-
(Locked)
-
-
-