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.
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.
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.
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
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?
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.
@@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.
@@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() #
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.
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
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.
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 😃👍🏻
@@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!
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
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 🤪
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
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.
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.
Thank you! I'm glad you found this helpful :)
The best flask file upload tutorial out there!
I appreciate that :)
Very clear, and answers common questions of beginners. Thank you!
You're welcome! Happy this was helpful.
Super tight, clear, and clean tutorial. I like the way you explain things too. This was very helpful, thank you Luke!
Thank you, Zack! :) Very glad this was clear and helpful.
Thanks Luke, there are few videos about this topic taught with such clarity
Hey thanks! Glad this was helpful :)
Wonderful explanation that I ever heard from TH-cam 🎉 .Thank you ❤
Haha, well thank you. I appreciate that 🙂
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.
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.
Thank you for this great tutorial!
Sir thank you for this awesome tutorial
how can I rename the filename for the uploaded files. so its easier for placing specific image in specific places?
very good video on the topic
How to upload many files and get a list of files at the application?
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
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.
Hey Manishankar, yes that's very easy! You can use the os.path.exists() function: snipsave.com/user/lukepeters/snippet/gluq0DnTDMgShg6yR2/
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?
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.
@@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.
@@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() #
Hi sir, thanku for the video, How to save these uploads in to the database.
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.
Deserves more likes and views
What if you're working with pdfs? How would you get it to display? Is it possible to do with tag?
A quick Google search (very helpful tool 😉) tells me that you can indeed load a PDF inside an . You can also use the tag.
I appreciate you took the time to comment back 🙏 @@LukePeters thank you
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
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.
super underrated , just one doubt , if I deploy it to Heroku still will this saving file to OS particular directory will work or not ?
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 😃👍🏻
@@LukePeters thanks 😊 and I have tried doing this in Heroku , it doesn’t allow
@@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!
@@allmighty2000 Hmm that sounds strange. Maybe read the documentation on the "to_csv()" function and see if that explains anything?
Thank you, this was really helpfull!
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
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 🤪
thanks bro
And even github the code you upload there is not complete please help me
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
you gotta be kidding me...there is nothing in your code link man
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.
🎨 Here's the CSS for this project: github.com/LukePeters/flask-file-uploads/blob/main/static/styles.css