Uploading Files with Flask - Everything You Need to Know

  Рет қаралды 12,257

Luke Peters

Luke Peters

Күн бұрын

Пікірлер: 48
@LORDJAVIE
@LORDJAVIE 8 ай бұрын
As somebody who is learning programming from youtube, I can say this is one of the best tutorials I've ever seen. The explanation is clear, the code is clean and cover all the basic elements to complete the task. I definitely will follow your content in the future. Thanks a lot, man.
@LukePeters
@LukePeters 7 ай бұрын
Thank you! I'm glad you found this helpful :)
@hszt4414
@hszt4414 2 жыл бұрын
The best flask file upload tutorial out there!
@LukePeters
@LukePeters 2 жыл бұрын
I appreciate that :)
@iFloxy
@iFloxy 2 жыл бұрын
Super tight, clear, and clean tutorial. I like the way you explain things too. This was very helpful, thank you Luke!
@LukePeters
@LukePeters 2 жыл бұрын
Thank you, Zack! :) Very glad this was clear and helpful.
@rinzu22
@rinzu22 Жыл бұрын
Very clear, and answers common questions of beginners. Thank you!
@LukePeters
@LukePeters Жыл бұрын
You're welcome! Happy this was helpful.
@eimajin8
@eimajin8 2 жыл бұрын
Thanks Luke, there are few videos about this topic taught with such clarity
@LukePeters
@LukePeters 2 жыл бұрын
Hey thanks! Glad this was helpful :)
@codingtochangetheworld5495
@codingtochangetheworld5495 9 ай бұрын
Wonderful explanation that I ever heard from KZbin 🎉 .Thank you ❤
@LukePeters
@LukePeters 7 ай бұрын
Haha, well thank you. I appreciate that 🙂
@oyugoobonyo7117
@oyugoobonyo7117 3 жыл бұрын
Great video! Absolutely helped me solve a bug that had been troubling me for days. I'd suggest you try using FlaskForm and its validators, a lot of your custom implementations like the allowed extensions configurations are already handled by flaskform.
@LukePeters
@LukePeters 3 жыл бұрын
Hey Oyugo, thanks for the comment. Glad to hear this video helped! I'll check out FlaskForm 👍🏻 I've never used it because my frontend is usually React, not Flask/Jinja2, and I just use Flask as a backend API.
@Kennethlumor
@Kennethlumor 3 жыл бұрын
Sir thank you for this awesome tutorial
@RaheEl_Qaisrani
@RaheEl_Qaisrani 9 ай бұрын
very good video on the topic
@joshuawalker7716
@joshuawalker7716 2 жыл бұрын
Deserves more likes and views
@andrewcarney8631
@andrewcarney8631 2 жыл бұрын
Thank you for this great tutorial!
@alejandrodejesusescarenofl4139
@alejandrodejesusescarenofl4139 2 жыл бұрын
Thank you, this was really helpfull!
@hamzawasfi5166
@hamzawasfi5166 5 ай бұрын
How to upload many files and get a list of files at the application?
@adithyaparashar4046
@adithyaparashar4046 Жыл бұрын
how can I rename the filename for the uploaded files. so its easier for placing specific image in specific places?
@aakshkr10
@aakshkr10 Жыл бұрын
thanks bro
@manishankarkonda7689
@manishankarkonda7689 3 жыл бұрын
Hi sir, thanku for the video, How to save these uploads in to the database.
@LukePeters
@LukePeters 3 жыл бұрын
Hey Manishankar, rather than saving files in the database directly, you should probably save the files in a folder on the filesystem, then save the FILENAME only to the database. Then when you need to use the file in a template, you can get the filename from the database and use the path you chose as your upload directory.
@manishankarkonda7689
@manishankarkonda7689 2 жыл бұрын
Hi luke, Is it recommended in production environment to first get the files into upload folder and than save it into the bucket. Is maintaining a folder is good?
@LukePeters
@LukePeters 2 жыл бұрын
Hi Manishankar, storing and serving files from a folder is 100% okay. This is how most websites on the internet serve files - from a folder on the server. Using a storage bucket from a company that offers this kind of service has some advantages. If you've used up the space on your web server (or anticipate having a LOT of large files), a bucket is probably cheaper per gigabyte than the filesystem on the average web server. Bucket services probably also have good file caching and a global content delivery networks, so files might be served up faster. But don't overcomplicate your tech stack if you don't need to! Use a bucket if you have a reason to, or if you just want to learn about buckets :) Otherwise, serving files from a folder is perfect.
@manishankarkonda7689
@manishankarkonda7689 2 жыл бұрын
@@LukePeters Got it sir. I Created a folder and uploaded the files in to that folder. I want to return those files with size. I am trying but i am getting file as a string not the actual file. How can i get the file size after uploading it to the folder.
@LukePeters
@LukePeters 2 жыл бұрын
​@@manishankarkonda7689 1) You can get the file size in memory like this: file = request.files['file'] file.seek(0, os.SEEK_END) file_size = file.tell() #
@Kennethlumor
@Kennethlumor 3 жыл бұрын
Sir please and please i want you to do a video on how to add a search to flask app (where for example an admin can search for a record of an item or anything that the result will display
@LukePeters
@LukePeters 3 жыл бұрын
Hi Kenneth, I will do a tutorial on searching in Flask at some point. It depends on what you're using for a database, though, since searching in MySQL is going to be slightly different than searching in MongoDB, etc.
@gregc.8186
@gregc.8186 9 ай бұрын
Hello, I dont know if you are active, but I am getting 403 errors in my python after clicking upload. I am using nginx/flask/gunicorn as my backend. Please advise and thank you
@allmighty2000
@allmighty2000 2 жыл бұрын
super underrated , just one doubt , if I deploy it to Heroku still will this saving file to OS particular directory will work or not ?
@LukePeters
@LukePeters 2 жыл бұрын
I don't use Heroku so I'm not sure how much access they give you to the filesystem. I think any files uploaded to their filesystem will be removed when the app is restarted, so that's obviously not good. You may have to use a third-party storage solution (i.e. Amazon S3 buckets). Or you could just buy a cheap little server from Linode and have full control over the whole system 😃👍🏻
@allmighty2000
@allmighty2000 2 жыл бұрын
@@LukePeters thanks 😊 and I have tried doing this in Heroku , it doesn’t allow
@allmighty2000
@allmighty2000 2 жыл бұрын
@@LukePeters I am replying back , because when I tried saving the CSV file using CSVFILE_NAME.to_csv("name.csv") then it actually worked, I am not sure if its bug but whenever inside "to_csv" method I am mentioning full path its showing me "Internal Error / Server Overload" , might be some kinda glitch!
@LukePeters
@LukePeters 2 жыл бұрын
@@allmighty2000 Hmm that sounds strange. Maybe read the documentation on the "to_csv()" function and see if that explains anything?
@manishankarkonda7689
@manishankarkonda7689 3 жыл бұрын
HI luke, Is it possible to search a file from the upload folder itself ,prior to saving it to the database. please recommend the solution.
@LukePeters
@LukePeters 2 жыл бұрын
Hey Manishankar, yes that's very easy! You can use the os.path.exists() function: snipsave.com/user/lukepeters/snippet/gluq0DnTDMgShg6yR2/
@BicMitchum-e7d
@BicMitchum-e7d Жыл бұрын
What if you're working with pdfs? How would you get it to display? Is it possible to do with tag?
@LukePeters
@LukePeters Жыл бұрын
A quick Google search (very helpful tool 😉) tells me that you can indeed load a PDF inside an . You can also use the tag.
@BicMitchum-e7d
@BicMitchum-e7d Жыл бұрын
I appreciate you took the time to comment back 🙏 @@LukePeters thank you
@nameaccelerate6249
@nameaccelerate6249 2 жыл бұрын
Sir please and please your tutorial is awesome but if you can reupload the code to the github, because it seems nothing is in the app.py file when you open it
@LukePeters
@LukePeters 2 жыл бұрын
There are two code branches on GitHub: "main" and "completed-tutorial". There's a link to the completed code right on the front page of the Git repository titled "Completed Code". Here's the direct link for you: github.com/LukePeters/flask-file-uploads/tree/completed-tutorial Also, why are you commenting three times from two different accounts? I saw the first comment 🤪
@Kennethlumor
@Kennethlumor 2 жыл бұрын
And even github the code you upload there is not complete please help me
@LukePeters
@LukePeters 2 жыл бұрын
The completed code is in GitHub. It's listed under the large bold heading that says "Completed Code". Here's a direct link for you: github.com/LukePeters/flask-file-uploads/tree/completed-tutorial
@ansarimohamed879
@ansarimohamed879 Жыл бұрын
you gotta be kidding me...there is nothing in your code link man
@LukePeters
@LukePeters Жыл бұрын
Huh? Did you look at the repo at all? The link for the initial code to begin the tutorial is here: github.com/LukePeters/flask-file-uploads And the code for the finished project is in a different branch there. There’s a big heading in the repo telling you where the completed code is.
@LukePeters
@LukePeters 3 жыл бұрын
🎨 Here's the CSS for this project: github.com/LukePeters/flask-file-uploads/blob/main/static/styles.css
How to Upload, Process, and Download CSV Files in Flask apps
17:26
Pretty Printed
Рет қаралды 25 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Beginner's Guide to the Bash Terminal
1:14:37
Joe Collins (EzeeLinux)
Рет қаралды 2,3 МЛН
Python + JavaScript - Full Stack App Tutorial
1:29:25
Tech With Tim
Рет қаралды 261 М.
Python REST API Tutorial - Building a Flask REST API
1:14:01
Tech With Tim
Рет қаралды 791 М.
Home Servers Have NEVER Been This Easy: CasaOS + ZimaBoard
49:58
Hardware Haven
Рет қаралды 752 М.
How to Upload Files with Flask Using Python
11:04
Arpan Neupane
Рет қаралды 76 М.
Uploading and Returning Files With a Database in Flask
6:38
Pretty Printed
Рет қаралды 39 М.