How to upload image in React Node and Mongo db using MULTER | Node JS + MULTER | Upload & Retrieve

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ก.ค. 2023
  • Hello Guys,
    Check out this amazing cloud platform:
    ZEGOCLOUD SDK provides easy video call SDK, voice call SDK, live streaming SDK and chat SDK for real-time interaction.
    Get ZEGOCLOUD SDK for 10,000 free mins: bit.ly/3OznGu6
    Pre-built UIKits in low codes: bit.ly/3SN4Ja1
    Create docs sites with Docuo now: bit.ly/3SOF5S0
    Top 10 video conferencing SDKs for you: bit.ly/3Sx6mHg
    #zegocloud #uikits #sdk #api #react
    In this tutorial I have shown you that how can you upload an Image from react to mongo db by creating an api in node js + multer and fetch it again and show it to your React Js application.
    Thank You.
    GitHub Link:
    github.com/the-debug-arena/mu...
    Node Js and Mongo Db tutorial.
    • #1 Explanation about h...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 83

  • @malikbhai2285
    @malikbhai2285 11 หลายเดือนก่อน

    thank you soo much for this video for me very helpful..lot of thanks

  • @naseeriyat9241
    @naseeriyat9241 8 หลายเดือนก่อน

    Thanks guru ji

  • @mario_luigie4593
    @mario_luigie4593 7 หลายเดือนก่อน

    Good Job! Thank you!

  • @doloresmampoko2463
    @doloresmampoko2463 4 หลายเดือนก่อน

    thank you but its not working for me , the bug started when i put the url front in multer stockage , can i have help plz ?.

  • @xeniyadobro380
    @xeniyadobro380 2 หลายเดือนก่อน

    Thank you!

  • @user-ei8mi6sz7q
    @user-ei8mi6sz7q 10 หลายเดือนก่อน +1

    amazing bro

    • @thedebugarena
      @thedebugarena  10 หลายเดือนก่อน

      You can checkout for pdf also

  • @idreamgames
    @idreamgames 5 หลายเดือนก่อน

    Amazing video but if you had saved it like baseurl/filename in database instead of getting it from local dir (src/images) that will be very helpful.

  • @jumbo999614
    @jumbo999614 ปีที่แล้ว +3

    Since both Base64 image file and regular image file have data type of String in MongDB, can we display both images at the same time using the same schema?
    Right now I'm able to upload both Base64 and regular filename to MongoDB using the same Schema.
    It would be great if there is some codes to check if the image is stored as filename or Base64 in MongoDB and display them properly.

    • @thedebugarena
      @thedebugarena  ปีที่แล้ว +1

      You can check my other video on the same but using multer. In that I am storing image name only

    • @jumbo999614
      @jumbo999614 ปีที่แล้ว +2

      @@thedebugarena Thanks again for replying.
      I have more questions.
      If you deploy the project onto the internet, where will the actual images be stored? on their server's storage disk?
      and on the Register page, you hardcode Admin secret key. Isn't security risk? The server that store your code will have access to this key?
      And the secret key will be able to update? Let' say someone accidentally finds out the secret key and you want to change it. What would you have to do?
      I'm just curious.

  • @malikbhai2285
    @malikbhai2285 10 หลายเดือนก่อน

    ok Bro, thanks image done..now make video for pdf file upload or download or video upload or play in mern stack wtih next.js

    • @thedebugarena
      @thedebugarena  10 หลายเดือนก่อน +1

      Sure will try

    • @thedebugarena
      @thedebugarena  10 หลายเดือนก่อน

      Video is out you can check

  • @sebastianmontoya7217
    @sebastianmontoya7217 8 หลายเดือนก่อน +1

    Thanks for the video this seems to be great for working in local. In the case of deploying to a host, is there a way we can get photos uploaded somewhere so that way we can pass the url of the image? All done from within the app? Like upload image in frontend, backend gets it uploaded to a third party, creates a url , and then adds that url to mongodb .. when we call mongodb it will have url of images which we can then map through and show

    • @thedebugarena
      @thedebugarena  8 หลายเดือนก่อน +3

      Yes while hosting also we can use multer and it works. But, there is one more solution which totally suits your requirement is using cloudinary. You can upload image there it will return url and then you can store that in mongo db. Very soon I will be posting video on this but you can checkout others.

    • @Shanky_17
      @Shanky_17 6 หลายเดือนก่อน

      Do it fast bro@@thedebugarena

  • @maheshbhatt1505
    @maheshbhatt1505 4 หลายเดือนก่อน +1

    Hey im getting this error Uncaught ReferenceError: require is not defined. why is it not defined or do i need to install some packages for that . Im using src={require(`./images/${data.image}`)} Please help at 16:45 part of your video

    • @thedebugarena
      @thedebugarena  4 หลายเดือนก่อน

      Ideally it should work. I don't know why it is giving you error but still try this solution

  • @malikbhai2285
    @malikbhai2285 11 หลายเดือนก่อน +1

    sir i want to upload pdf file or video then video play and pdf file download

  • @ShanuKhan-jx4xy
    @ShanuKhan-jx4xy 2 หลายเดือนก่อน

    How to Validate form-data before using Multer ?

  • @malikbhai2285
    @malikbhai2285 11 หลายเดือนก่อน

    bhai mere pass frontend me ja ker image save ni ho rhii..?

  • @nagaBhushan-pb6gu
    @nagaBhushan-pb6gu 8 วันที่ผ่านมา

    Disk storage is not working after deployment

  • @rajeshramjibanswal1277
    @rajeshramjibanswal1277 10 หลายเดือนก่อน +1

    Suppose we get image outside the project folder using API then what should I do

    • @thedebugarena
      @thedebugarena  10 หลายเดือนก่อน

      Then we might have to use an external package which will allow this

    • @thedebugarena
      @thedebugarena  10 หลายเดือนก่อน

      The solution is given in my next video in which i have shown how to upload pdf

  • @meow3065.
    @meow3065. ปีที่แล้ว +1

    what will happen if i host my website will the uploads folder still contain the images for particular user or how does it work

    • @thedebugarena
      @thedebugarena  11 หลายเดือนก่อน

      There you have to manage the folder structure accurately but it works there

    • @LukmaansStack
      @LukmaansStack 9 หลายเดือนก่อน

      how to manage that folder structure please tell me
      @@thedebugarena

    • @thedebugarena
      @thedebugarena  9 หลายเดือนก่อน

      @@LukmaansStack While hosting there are few things we have to do 1) To whatever folder you are adding the image it should have access to read and delete. 2) You have to specify proper location to upload the image.

  • @marvelworld5210
    @marvelworld5210 10 หลายเดือนก่อน +1

    Bro mene frontend & backend ke liye alg se folder bana rakhe hai 2, and backend me index.js hai java multer laga hai and fronted wale folder me react hai.
    Problem: Multer destination cb(null, ".../fronted/src/component/") frontend path dalne per image phoch nahi rahi hai image folder me.
    Please help ❤️

    • @thedebugarena
      @thedebugarena  10 หลายเดือนก่อน

      In that case you can put them in same folder or you have to use some external package to achieve them

    • @marvelworld5210
      @marvelworld5210 10 หลายเดือนก่อน

      @@thedebugarena yes unfortunately now I'm using all the fronted and backend in same folder 🥲

    • @thedebugarena
      @thedebugarena  10 หลายเดือนก่อน

      @@marvelworld5210 Ohhh luckily now I got the best solution of this also in my next video I will show that

  • @renzxstech1761
    @renzxstech1761 4 หลายเดือนก่อน

    how about my backend and react app is in the different directory?

    • @thedebugarena
      @thedebugarena  4 หลายเดือนก่อน

      You can do this by creating a static folder in your backend where you can store any files that can be accessible for anywhere.

  • @AbiRamABII
    @AbiRamABII 7 หลายเดือนก่อน

    bro in backend while store , what should define the path name for storing the images after deployment

    • @thedebugarena
      @thedebugarena  6 หลายเดือนก่อน +1

      After deployment if your backend folder is at same location then same code should work. You can access the folder like this './uploads'. But if your both the folder is at different location then we can do like this: Suppose your image is getting uploaded into "Uploads" folder at the backend using multer then in app.js we can add this line "app.use("/uploads,express.static("uploads")) this will make your uploads folder static and it can be accessed from anywhere. Then in your react you can access image using location like "localhost:5000/uploads/file.jpg". In place of localhost you can pass your url.
      For better understanding you can watch this video th-cam.com/video/Fvp6EDIPSCU/w-d-xo.htmlsi=hPijFFEHqPgO4M1w at timeline 17:38

    • @AbiRamABII
      @AbiRamABII 6 หลายเดือนก่อน

      @@thedebugarena tnx bro ,you're a lifesaver!

  • @gamingarena5045
    @gamingarena5045 ปีที่แล้ว

    I'm doing the same but it says require is not defined when I write require in my img tag.

  • @deepikadeepu9534
    @deepikadeepu9534 หลายเดือนก่อน

    If you deploy the project onto the internet, where will the actual images be stored? on their server's storage disk? can anyone answer this please

    • @user-ne6hw3er4n
      @user-ne6hw3er4n หลายเดือนก่อน +1

      Yeah bro

    • @thedebugarena
      @thedebugarena  หลายเดือนก่อน +1

      Yes it will be stored on Server's storage disk.

  • @user-bp9wb4oc8z
    @user-bp9wb4oc8z 3 หลายเดือนก่อน

    no need to use buffer as a datatype while we store an image to mongodb ???

    • @thedebugarena
      @thedebugarena  3 หลายเดือนก่อน

      Yes you can change your datatype to buffer but string is also doing the job so I used that.

  • @digitaltanzeel1056
    @digitaltanzeel1056 10 หลายเดือนก่อน

    how can we my backend app name is backend and frontend app name is frontend , how can we give image folder location in backend in place of upload file .. will it work , please let me know

    • @thedebugarena
      @thedebugarena  10 หลายเดือนก่อน

      Yes it will work. If you are having two different folders at different location then you might have too work hard and use some External package to achieve that

  • @sreenija3703
    @sreenija3703 8 หลายเดือนก่อน

    i have a form which consist of personal details and image .How to set mongodb schema for this type of data.Can we send text and image data at a time to server

    • @thedebugarena
      @thedebugarena  8 หลายเดือนก่อน +1

      Yes you can in this in schema we have added only image you can add other things too. In front-end store all the different values like name, image etc in their particular state and on submit send them all to backend. It will work

    • @sreenija3703
      @sreenija3703 8 หลายเดือนก่อน

      @@thedebugarena can you please make a video on that type of form too

  • @mustkeemkhokhar7030
    @mustkeemkhokhar7030 10 หลายเดือนก่อน

    bro try both axios and and browser fectch api got same api error 404 page not found.. any help

    • @thedebugarena
      @thedebugarena  10 หลายเดือนก่อน

      Dm me on instagram

  • @iganic7574
    @iganic7574 7 หลายเดือนก่อน +2

    is we can't save entire image in mongodb in binary form ?

    • @thedebugarena
      @thedebugarena  7 หลายเดือนก่อน

      We can store in base 64 check previous video in that I have done using base 64.

    • @friday077
      @friday077 5 หลายเดือนก่อน

      @@thedebugarenai think it just encode the filename but he ask about the is it possible to upload a image direct with out any create folder like upload

    • @afifnusada4712
      @afifnusada4712 5 หลายเดือนก่อน

      bruh, your grammar is a disaster💀💀, this is the first time i see a person using “is” and “can’t” at the same time💀💀.

    • @thedebugarena
      @thedebugarena  5 หลายเดือนก่อน

      @@afifnusada4712 sorry about that. Will improve.

  • @gauravbhagat2506
    @gauravbhagat2506 9 หลายเดือนก่อน +1

    What if i want to host this app. Now it will not work right?

    • @thedebugarena
      @thedebugarena  9 หลายเดือนก่อน

      Yes it will work. While hosting you just have to give that folder read and write access.

  • @pawanyadav4417
    @pawanyadav4417 7 หลายเดือนก่อน

    what if frontend is at another place how to tell backend to use src

    • @thedebugarena
      @thedebugarena  6 หลายเดือนก่อน

      In that case what we can do is Suppose your image is getting uploaded into "Uploads" folder at the backend using multer then in app.js we can add this line "app.use("/uploads,express.static("uploads")) this will make your uploads folder static and it can be accessed from anywhere. Then in your react you can access image using location like "localhost:5000/uploads/file.jpg".
      For better understanding you can watch this video th-cam.com/video/Fvp6EDIPSCU/w-d-xo.htmlsi=hPijFFEHqPgO4M1w at timeline 17:38.

  • @ranjitdevadiga6880
    @ranjitdevadiga6880 4 หลายเดือนก่อน

    will this work fine when we deploy it.

    • @thedebugarena
      @thedebugarena  4 หลายเดือนก่อน +1

      We will have to configure it properly but it should work

  • @008ajaykumarpaswan6
    @008ajaykumarpaswan6 8 หลายเดือนก่อน

    bhai here uploads folder is automatically made or have to made

  • @shahinrohaman6257
    @shahinrohaman6257 4 หลายเดือนก่อน +1

    I got network error: axios error how can I fix it

    • @logicfy
      @logicfy 3 หลายเดือนก่อน

      check endpoint

  • @malikbhai2285
    @malikbhai2285 11 หลายเดือนก่อน

    bro same this work with next.js full stack make video?

    • @thedebugarena
      @thedebugarena  11 หลายเดือนก่อน +1

      Dm me on instagram

    • @malikbhai2285
      @malikbhai2285 10 หลายเดือนก่อน

      @@thedebugarena what mean this?

  • @kuretinamahsivaya5469
    @kuretinamahsivaya5469 3 หลายเดือนก่อน

    how can i send 2 or more images in array

    • @thedebugarena
      @thedebugarena  3 หลายเดือนก่อน

      I input tag there is option of multiple by using that you can select multiple image but In backend you will have to modify according to that

    • @kuretinamahsivaya5469
      @kuretinamahsivaya5469 3 หลายเดือนก่อน

      @@thedebugarena please tell me also that

  • @KadamVaibhav-gn8pw
    @KadamVaibhav-gn8pw 3 หลายเดือนก่อน

    where is your code

  • @Aben7331
    @Aben7331 11 หลายเดือนก่อน

    Hello can u please help me I get stucked🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

    • @thedebugarena
      @thedebugarena  11 หลายเดือนก่อน

      Dm me on instagram

  • @viveksoni7217
    @viveksoni7217 5 หลายเดือนก่อน

    bhai deploy bhi krne ka bana deta 🥲

  • @user-bh5yg6cy5l
    @user-bh5yg6cy5l ปีที่แล้ว

    Pleas share source code in github repasetory

    • @thedebugarena
      @thedebugarena  ปีที่แล้ว

      github.com/the-debug-arena/multer-image-upload.git