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...

КОМЕНТАРІ • 74

  • @nozkieful
    @nozkieful 4 роки тому +33

    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.

    • @piyushaggarwal5207
      @piyushaggarwal5207 2 роки тому +3

      thanks for saving my time. Everybody is like saving to monogodb. I don't know why. I am tired.

    • @pp0pp09
      @pp0pp09 2 роки тому

      @@piyushaggarwal5207 use gridFS to store actually in the mongoDB..bt it has a limitation on file size(upto 16MB only)

    • @nathanmorlonski1265
      @nathanmorlonski1265 2 роки тому +2

      @@pp0pp09 no, gridFS allows you to upload files MORE than 16MB

    • @sohigh7433
      @sohigh7433 4 місяці тому

      ​@@nathanmorlonski1265 MongoDB's document size is capped to 16MB

  • @geodev
    @geodev 2 роки тому +3

    You saved my life! Very clear explanation. Thank you very much for the amazing tutorial!

  • @sagarp7516
    @sagarp7516 4 роки тому +1

    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...🙂🙂

  • @krishna7440
    @krishna7440 4 роки тому +15

    bro lesson was literally amazing but it would be very helpful if u could share codes as well or github link

  • @ShivamSingh-sv6rh
    @ShivamSingh-sv6rh 4 роки тому +6

    I am not able to get this video above 360p.

    • @cyan3675
      @cyan3675 4 роки тому

      Yep, i cant use 480p

  • @ankitapaul1031
    @ankitapaul1031 Рік тому +1

    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

    • @megamarvellous3521
      @megamarvellous3521 Рік тому

      You might need to move the images manually to the uploads folder

  • @mohammedshoaib2755
    @mohammedshoaib2755 3 роки тому

    Awsome sir...You are down to Earth

  • @shakilahmed6870
    @shakilahmed6870 Рік тому +1

    My right ear is felling so alone

  • @jimspatel2407
    @jimspatel2407 2 роки тому

    Thank you so much .
    To the point video great explanation.
    Thank you once again 😊

  • @bulentyildiz07
    @bulentyildiz07 4 роки тому

    very well done, keep it up.
    a big thank you to you

  • @AmazonFinds-001
    @AmazonFinds-001 2 роки тому +1

    MulterError: Unexpected field
    at wrappedFileFilter (D:
    odejs
    ode_modules\multer\index.js:40:19) I get this error

  • @tinkun23
    @tinkun23 4 місяці тому

    ur video make me bum bum bro, so greatttt

  • @betterbehappythannot3605
    @betterbehappythannot3605 Рік тому +1

    Is there a link to github or smth?

  • @malachitto7113
    @malachitto7113 6 місяців тому

    Thank you so much for ur wonderful videos

  • @danielklassicug6947
    @danielklassicug6947 2 роки тому

    you have saved my day
    Thanks alot master🥰🥰

  • @NSTuts
    @NSTuts 2 роки тому

    and what is the file upload is there from multiple fields

  • @KundanKumar-sx2vm
    @KundanKumar-sx2vm 4 роки тому

    Amazing tutorial .. great thanks 😍

  • @shahzaibali8146
    @shahzaibali8146 2 роки тому +1

    Error: ENOENT: no such file or directory, open 'uploads/1657119064526.png'
    Anyone have solution of this problem

  • @maxmaksum4673
    @maxmaksum4673 3 роки тому

    you are such awesome teacher..you should make mern stack and social media clone

  • @preshitwtf
    @preshitwtf 2 роки тому

    Thanks sir, This helped me alot

  • @kadirramazn
    @kadirramazn Рік тому

    you are great man thanks

  • @liveecofriendly1116
    @liveecofriendly1116 2 роки тому

    not only images, also share the code to upload .txt, pdf, excel and other files to mongodb

  • @boscofan3735
    @boscofan3735 2 роки тому

    how do you use form-data to send boolean or number value? you are sending string only

  • @MkaifMansoori
    @MkaifMansoori Рік тому

    how to update multiple files plz explain i am stuck in this every help is appriciate

  • @darshitashah2986
    @darshitashah2986 2 роки тому

    I am getting this error, can you please help
    ReferenceError: File is not defined

  • @fjacyntho
    @fjacyntho 4 роки тому +2

    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?

  • @viperdamodargaming955
    @viperdamodargaming955 4 роки тому

    want to fetch those comma seperated images help me how can i do ?

  • @Munnapathania
    @Munnapathania 4 роки тому

    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

  • @shivkumartotagi2018
    @shivkumartotagi2018 4 роки тому

    form-data is not working show ing me the same error

  • @JayanThrissur
    @JayanThrissur 2 роки тому

    Thank you very much .

  • @tanvirulislam4120
    @tanvirulislam4120 2 роки тому

    how can remove file or delete file from server or temp folder.. please add a separate video.... i personally request for this video

  • @johnyanastacio1107
    @johnyanastacio1107 4 роки тому

    thank you!!

  • @TechFounder
    @TechFounder  11 місяців тому

    To Download the Source Codes & Postman Collection of full series (8 videos), please click here-
    techfoundercreator-springcom.creator-spring.com/listing/nodejs-mongodb-tutorial

  • @m12652
    @m12652 9 місяців тому

    I was expecting a save to MongoDB

    • @TechFounder
      @TechFounder  8 місяців тому

      mongodb don't allow file saving, you must have to save in server

    • @m12652
      @m12652 8 місяців тому

      @@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

    • @m12652
      @m12652 5 місяців тому

      @@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.

  • @stavroskefaleas6320
    @stavroskefaleas6320 Рік тому

    I get upload.single is not a function

  • @coderx4248
    @coderx4248 Рік тому

    Thanks a lot

  • @grandmaster705
    @grandmaster705 3 роки тому

    Thanks 🌹

  • @onphuocnguyen7849
    @onphuocnguyen7849 2 роки тому

    i can't send request with formdata same you

  • @Casal0x
    @Casal0x 4 роки тому

    i'm following your tutorial but i have an error, do you have any public repository with the code?

  • @dangkhanh5328
    @dangkhanh5328 10 місяців тому

    Is it can be working with audio files ?

    • @TechFounder
      @TechFounder  10 місяців тому

      yes, upload system is same, but you should allow audio extensions

  • @thepickleic-4362
    @thepickleic-4362 4 роки тому

    Una gran ayuda (Y)

  • @poojat2137
    @poojat2137 3 роки тому

    can u share this code?

  • @muhammadfarooq4694
    @muhammadfarooq4694 3 роки тому

    I want to upload pdf file rather than jpg or png so can anyone tell me how I can do this?

    • @TechFounder
      @TechFounder  3 роки тому

      Yes you can do it in same way, just add mimetype for pdf.

  • @klue2708
    @klue2708 3 роки тому

    This only works for png, i don't know why but It didn't work for the jpg

    • @fierstever1235
      @fierstever1235 3 роки тому

      instead of file.mimetype == "image/jpg" use file.mimetype == "image/jpeg". It worked for me..

    • @TechFounder
      @TechFounder  3 роки тому

      Yes great addition, thanks!

    • @fierstever1235
      @fierstever1235 3 роки тому

      @@TechFounder no worries man. Im always happy to help!

    • @TechFounder
      @TechFounder  3 роки тому

      @@fierstever1235 Thanks, no sir it will works for any kinds of file type. Please just customize your code as you need

  • @JWhitty
    @JWhitty 3 роки тому

    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

    • @TechFounder
      @TechFounder  3 роки тому

      Please create a blank uploads folder manually, check directory permission. Check multer properly installed.

    • @JWhitty
      @JWhitty 3 роки тому

      @@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

    • @JWhitty
      @JWhitty 3 роки тому

      @@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

  • @mathewsjoby6455
    @mathewsjoby6455 2 роки тому

    The whole video was playing on my left ear! try to improve next time

    • @TechFounder
      @TechFounder  2 роки тому

      Sure, thanks for being with us

    • @mathewsjoby6455
      @mathewsjoby6455 2 роки тому

      @@TechFounder thankyou for the good, honest and kind reply! good luck

    • @mathewsjoby6455
      @mathewsjoby6455 2 роки тому

      @@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

    • @TechFounder
      @TechFounder  2 роки тому

      @@mathewsjoby6455 Can you do it yourself in Heroku if I show how to host in Digital Ocean?

  • @medhabibbenyoussef9391
    @medhabibbenyoussef9391 8 місяців тому

    you're not even teaching you just type like a robot

  • @SRIDHARI
    @SRIDHARI 2 роки тому

    Thank you 😊