NodeJS and MongoDB Tutorial #4 - Uploading Files (Single & Multiple)
Вставка
- Опубліковано 11 вер 2024
- To Download the Source Codes & Postman Collection of full series (8 videos), please click here-
techfoundercre...
Discussed Topics:
i) How to upload file/image in nodejs
iv) How to upload multiple files/images in nodejs
Videos of this Node JS and MongoDB tutorial series:
1) Installation - • NodeJS and MongoDB Tut...
2) Create a Node server - • NodeJS and MongoDB Tut...
3) Complete CRUD Operation - • NodeJS and MongoDB Tut...
4) File Upload (Single & Multiple) - • NodeJS and MongoDB Tut...
5) Complete Login Registration Process - • NodeJS and MongoDB Tut...
6) Authenticate routes - • NodeJS and MongoDB Tut...
7) Refresh Token - • NodeJS and MongoDB Tut...
8) Environment Variables - • NodeJS and MongoDB Tut...
9) Pagination - • NodeJS and MongoDB Tut...
This is not uploading file to mongodb, it is uploading to server file system then using the static folder path as a reference to mongodb. correct me if i’m wrong.. great tutorial anyway.. thanks.
thanks for saving my time. Everybody is like saving to monogodb. I don't know why. I am tired.
@@piyushaggarwal5207 use gridFS to store actually in the mongoDB..bt it has a limitation on file size(upto 16MB only)
@@pp0pp09 no, gridFS allows you to upload files MORE than 16MB
@@nathanmorlonski1265 MongoDB's document size is capped to 16MB
You saved my life! Very clear explanation. Thank you very much for the amazing tutorial!
Thank you very much
Wonderful teaching...clean maintained code... awesome... keep going sir... this type of teaching would help lots of people... thanks once again..I think if u continue like this u will going beat all of the channels...🙂🙂
bro lesson was literally amazing but it would be very helpful if u could share codes as well or github link
I am not able to get this video above 360p.
Yep, i cant use 480p
Hello, I tried uploading file as you said but in my project "uploads" folder I cannot see the file as you mentioned. In POSTMAN, I am getting as Added Employee successfully. But cannot see the object mainly the "avatar" neither in mongodb nor in POSTMAN
You might need to move the images manually to the uploads folder
Awsome sir...You are down to Earth
My right ear is felling so alone
Thank you so much .
To the point video great explanation.
Thank you once again 😊
very well done, keep it up.
a big thank you to you
MulterError: Unexpected field
at wrappedFileFilter (D:
odejs
ode_modules\multer\index.js:40:19) I get this error
ur video make me bum bum bro, so greatttt
Is there a link to github or smth?
Thank you so much for ur wonderful videos
you have saved my day
Thanks alot master🥰🥰
and what is the file upload is there from multiple fields
Amazing tutorial .. great thanks 😍
Error: ENOENT: no such file or directory, open 'uploads/1657119064526.png'
Anyone have solution of this problem
in upload.js look the path line 6
you are such awesome teacher..you should make mern stack and social media clone
Thanks sir, This helped me alot
you are great man thanks
not only images, also share the code to upload .txt, pdf, excel and other files to mongodb
how do you use form-data to send boolean or number value? you are sending string only
how to update multiple files plz explain i am stuck in this every help is appriciate
I am getting this error, can you please help
ReferenceError: File is not defined
Hello
Thank you for your video lesson.
Ask me a question:
How do I include multiple image fields in MongoDB, with the same number of images.
For example:
image avatar1 = field avatar1
image avatar2 = field avatar2
...
using the upload.array option?
want to fetch those comma seperated images help me how can i do ?
bro i have an doubts in my model schemas regarding images like array inside array so let me know how i can contact with you. If you will able to help me then i will be very thankful to you
form-data is not working show ing me the same error
Thank you very much .
how can remove file or delete file from server or temp folder.. please add a separate video.... i personally request for this video
thank you!!
To Download the Source Codes & Postman Collection of full series (8 videos), please click here-
techfoundercreator-springcom.creator-spring.com/listing/nodejs-mongodb-tutorial
I was expecting a save to MongoDB
mongodb don't allow file saving, you must have to save in server
@@TechFounderof course MongoDB allows saves, it’s a database and has tools for saving files (gridfs). This video is pointless and not what the title suggests
@@ferreiradelima96 thats why its being pushed as a viable solution then...? Storing files in a database was a bad idea a decade ago, now its not such a bad idea. If you need proper permissions control its a lot easier to implement (and much cheeper) than setting up a file server and domain controller etc.
I get upload.single is not a function
Thanks a lot
Thanks 🌹
i can't send request with formdata same you
i'm following your tutorial but i have an error, do you have any public repository with the code?
Can you share your error?
Is it can be working with audio files ?
yes, upload system is same, but you should allow audio extensions
Una gran ayuda (Y)
can u share this code?
I want to upload pdf file rather than jpg or png so can anyone tell me how I can do this?
Yes you can do it in same way, just add mimetype for pdf.
This only works for png, i don't know why but It didn't work for the jpg
instead of file.mimetype == "image/jpg" use file.mimetype == "image/jpeg". It worked for me..
Yes great addition, thanks!
@@TechFounder no worries man. Im always happy to help!
@@fierstever1235 Thanks, no sir it will works for any kinds of file type. Please just customize your code as you need
this neither creates and upload folder nor populates it with the file even though in my mongoDB I can see the file pathname uploaded and all of my code functions without throwing errors...
Why is multer not taking the actual file and making a copy in the Uploads folder? By the way "uploads/" throws errors, but "../uploads" doesnt and everything SEEMS to work but doesn't upload the file to the folder. I have no freakin clue where to console.log() to try to find the error here and see what is / isn't happening with the file "uploaded". I think it's just uploading a string that is the file path and then not actually moving the file
Please create a blank uploads folder manually, check directory permission. Check multer properly installed.
@@TechFounder directory permission? you don't even do that in your video. I will check this but i thnik it's something else. i already created the folder myself and i did not use "uploads/" because that causes another error saying the directory doesnt exist. "../uploads" from where my middleware "fileUpload" file is seems to work without errors, but isnt uploading/moving the file. Multer cannot be "improperly" installed... I did npm i multer in the project where the package.json is located for my server folder
@@TechFounder Error: ENOENT: no such file or directory, open '../uploads/5088_chickenegg.jpg'
this is all i get after making the folder (or if i use your code and don't make it, or do make it) nothing ever works
The whole video was playing on my left ear! try to improve next time
Sure, thanks for being with us
@@TechFounder thankyou for the good, honest and kind reply! good luck
@@TechFounder by the way can you make a video on how to host this on heroku please? I am not getting the concept properly anywhere! I need it quick cuz I have to submit it soon for my school. Made a beautiful blog but sadly doesn't work because of not being able to publish
@@mathewsjoby6455 Can you do it yourself in Heroku if I show how to host in Digital Ocean?
you're not even teaching you just type like a robot
Thank you 😊
You are welcome!