Multiple Image Uploader Using Node Express & MongoDB

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • In this video, we are going to learn how to create this beautiful node image uploader project using node express and MongoDB.
    In this project, we're gonna upload images in the MongoDB database and display them on the template.
    We gonna learn :
    * We will learn how to work with MVC patterns to create large projects.
    * We gonna see how to follow the programming principle.
    * You will also understand how to work with the Handlebars template engine.
    * How to store images in the MongoDB database. As well as we gonna store all the images in the upload folder of the server.
    * You gonna learn how to make a backend API for this project. And you will learn a lot more than this.
    I will explain each and every step to make you feel more comfortable.
    So let me show you the demo of this project.
    This is a beginner-friendly tutorial. So if you want to be a full stack developer this is the right tutorial for you.
    Follow me to take a step ahead to be a full stack developer.
    Checkpoints:-
    Introduction: 00:00
    Project Setup: 01:50
    HTTP Server: 04:51
    View Engine: 09:04
    Template Design: 15:06
    API: 27:46
    Multer Module: 31:57
    MongoDb Connection: 46:13
    Schema: 55:25
    Fetch Images: 01:13:17
    GitHub Repo:
    github.com/akashyap2013/Image...
    Comment us if you have any question or
    👉 Support Me on Patreon 😊:
    / dailytuition
    Udemy Courses:
    www.udemy.com/user/akshay-kas...
    👉 Follow us:
    / akki.2013
    👉 Learn More From Our Website:-
    www.dailywebtuition.com
    More Videos:
    **************************************************************************
    📹 Complete Mobile Shopee E-Commerce Website Course - PHP & MySQL
    • Complete Mobile Shopee...
    **************************************************************************
    📹 Complete Portfolio Website with Bootstrap - HTML/CSS
    • Complete Portfolio Web...
    **************************************************************************
    📹 Complete Responsive Blooger Website Using HTML/CSS
    • Complete Responsive Bl...
    **************************************************************************
    📹 Create a Shopping Cart Using PHP and Mysql
    • Create Shopping Cart U...
    **************************************************************************
    📹 Asp.net Registration Form Design with Validation Part - 1
    • Asp.net Registration F...
    **************************************************************************
    📹 Complete CRUD Operation with PHP MySql Database
    • Complete CRUD Operatio...
    **************************************************************************
    📹 What is Node.js? How to install it?
    • What is Node.js? Only ...
    **************************************************************************
    📹 PHP Complete Registration & Login System Using MySQLi - Complete Guide
    • PHP Complete Registrat...
    **************************************************************************
    📹 Hosting WordPress Website with Free Hosting
    • Hosting Wordpress Webs...
    **************************************************************************
    📹 Bootstrap Grid System The Complete Guide - In Action
    • Asp.net Registration F...
    **************************************************************************
    Node Tutorials:-
    👉 What is Node? Node For Beginners - 01
    • What is Node? Learn Wi...
    👉 Installing Node Node For Beginners - 02
    • Installing Node With E...
    👉 How to use REPL? Node For Beginners - 03
    • How To Use REPL ( Read...
    👉 Node Script Execution - Node For Beginners - 04
    • Working With Node Scri...
    👉 Working With Modules - Node For Beginners - 05
    • Working With Module - ...
    👉 What is NPM? - Node For Beginners - 06
    • What is NPM ( Node Pac...
    👉NPM Script & Type of Packages - - Node For Beginners - 07
    • NPM Scripts & Type of ...
    👉How To Use NPX In Node - Node For Beginners - 08
    • How To Use NPX In Node...
    👉Package Versions & Uninstalling Packages - Node For Beginners - 09
    • Package Versions & Uni...
    👉 What is Event Loop - Node For Beginners - 10
    • What is Event Loop - N...
    👉 Understanding Callback Functions - Node For Beginners - 11
    • Understanding Callback...
    👉 Working with Promises - Node For Beginners - 12
    • Working with Promises ...
    👉 Asynchronous Code With Async & Await - Node For Beginners - 13
    • Asynchronous Code With...
    👉 How to Create HTTP Server In Node - Node For Beginners - 14
    • How to Create HTTP Ser...
    👉 Making HTTP Request - Node For Beginners - 15
    • Making HTTP Request - ...
    👉 HTTP POST Request - Node For Beginners - 16
    • Creating HTTP POST Req...
    👉 Working With Files - Node For Beginners - 17
    • Working With Files - N...
    Attribution
    Background Music: www.bensound.com
    Images: www.freepik.com/vectors/school
    If you have any question please comment me on my video or you can write it on channel discussion.
    Thank You...! 🙏

Komentáře • 160

  • @orangeshoes
    @orangeshoes Před 3 lety +4

    Two minutes into this video and I already know you must have been really good at explaining this. Love your delivery!

  • @kimmoramicky
    @kimmoramicky Před 3 lety +11

    Honestly this is a great course, I was almost giving up on where to find how to do this before I saw this course.. You're the best man!

    • @DailyTuition
      @DailyTuition  Před 3 lety +1

      Most welcome 😊

    • @Lalit_Namdev
      @Lalit_Namdev Před rokem

      Hello sir
      I am facing this error when I upload images to the database == ​ "err": "cannot create a new collection -- already using 504 collections of 500"

  • @orangecode2668
    @orangecode2668 Před 3 lety +1

    you did what i want!
    thank you so much!!

  • @raj.rajput
    @raj.rajput Před 3 lety +2

    I really appreciate your work! Thank you so much, man!

  • @shubhamtripathy1685
    @shubhamtripathy1685 Před 2 lety +1

    Thanks for this video, it helps a lot.

  • @Jane-ge7ho
    @Jane-ge7ho Před 3 lety +1

    Thanks. Keep it up 👍👍👍

  • @tyland777
    @tyland777 Před 3 lety +2

    Thank you ! Great video. You are an excellent teacher !

  • @neroqa7810
    @neroqa7810 Před 3 lety +1

    Thank you very good and meaningful video 😍😍

  • @ishaan380
    @ishaan380 Před 2 lety +1

    Thanks for this super useful video

  • @snovegimank6195
    @snovegimank6195 Před 3 lety +1

    awesome!! thanks man

  • @islammohamed3023
    @islammohamed3023 Před 2 lety +1

    Great explanation

  • @brijeshcodehub7883
    @brijeshcodehub7883 Před 3 lety +1

    Thanks .keep it up

  • @joaonascimento3574
    @joaonascimento3574 Před 3 lety +1

    First one seeing this video. Love you channel! Thanks for uploading this helpful videos!

  • @ameenschools
    @ameenschools Před 2 lety +1

    am reaaly enjoying watching this tutorial. your code is really clean and your explanation is truly clear and crisp🙌🏻👏🏻🔥

  • @hondaxblade2127
    @hondaxblade2127 Před 3 lety +2

    You're on fire 🔥
    Love this project and created step by step 😍😍

  • @passioncorners
    @passioncorners Před 3 lety +1

    Man, anyone know the vscode theme and font that Daily Tuition used? It's so nice !

  • @RidwanurRahmanextreme
    @RidwanurRahmanextreme Před 3 lety +3

    You taught the whole thing so painstakingly, I loved the way you showed every tiny detail. You should make udemy courses or your own courses so that we could learn more. God bless you, sir.

  • @SaradaChitluri
    @SaradaChitluri Před 5 měsíci

    Thanks

  • @yunusemrebitkay774
    @yunusemrebitkay774 Před 2 lety +1

    Thank you so muchhhhhhhhhhhhhhhhhhhhhhhhh

  • @fgkttydggdydggdf3059
    @fgkttydggdydggdf3059 Před 2 lety +2

    Hi Guy you are good all the best

  • @anshuranjan4428
    @anshuranjan4428 Před 3 lety +1

    Hi, Followed each step but my bootstrap card is not finding the image? Can you help out?

  • @romanryaboshtan9270
    @romanryaboshtan9270 Před 2 lety +2

    37:07 instead store = multer({ storage: storage }) you can write store = multer({ storage }); It's a truncated write form

  • @movocode
    @movocode Před 3 lety +1

    👌👍

  • @alexandermejia3839
    @alexandermejia3839 Před 2 lety

    Hi!! Excelent content, I understand at least the 80% of the content, but I'm traying to create my own implementation of this. My question is, In postman what's the field name to share the images files? In all the tests at the moment it response with a "unexpected field" error. I'm getting without options.

  • @Lalit_Namdev
    @Lalit_Namdev Před rokem

    ​ @Daily Tuition I am facing this error when I upload images to the database == ​ "err": "cannot create a new collection -- already using 504 collections of 500"

  • @mrinalpramanick3053
    @mrinalpramanick3053 Před 2 lety +2

    Sir there one Error : in 9:59 you have written hbs({....})so some typo error will be occurring that hbs is not a function. it should be hbs.engine

  • @ujenbasi9495
    @ujenbasi9495 Před 3 lety

    can you please help me i am not able to fetch the image in react. please help me.

  • @zainhaider1633
    @zainhaider1633 Před 3 lety

    Can you please help me out to store and display images in react and mongodb

  • @raymak8533
    @raymak8533 Před 3 lety +1

    sir this video was really good ,but make the same tutorial for ejs instead of hbs.

  • @ialtoobi
    @ialtoobi Před 2 lety +1

    I love the way you teach, every thing clean and easy to understand.. Thanks a lot for your time and hard work to share your knowledge

  • @mila3538
    @mila3538 Před 2 lety +2

    This is an amazing tutorial ,thank you so much,
    Can you please tell me why we changed the images into base64? Will it increase the database size? Or cause problems with the 16MB document limitation of mongoDB?

    • @DailyTuition
      @DailyTuition  Před 2 lety

      Base64 images are primarily used to embed image data within other formats like HTML, CSS, or JSON. there is a need to encode binary data that needs be stored and transferred over media This is to ensure that the data remains intact without modification during transport.

    • @mila3538
      @mila3538 Před 2 lety +1

      @@DailyTuition thank you for your reply i appreciate it💙

  • @it_rashi3585
    @it_rashi3585 Před 3 lety +2

    Hey I'm working with ejs instead of hbs. Could you pls tell me how to use async and await in ejs? Its giving SyntaxError: Unexpected identifier. Please let me know.

  • @BilalAhmed-tw5cr
    @BilalAhmed-tw5cr Před rokem +1

    hi sir , i have a question the image should it be type String , coz am using data:buffer and its saying undefined on my image schema

    • @DailyTuition
      @DailyTuition  Před rokem

      Means it is not getting that store image. Make sure you insert it properly and fetch it.

  • @zanosajuela4665
    @zanosajuela4665 Před 3 lety

    hi nice video, can you send me the delete function for this ? :) for the router and collection

  • @hgsbrodi
    @hgsbrodi Před 2 lety +1

    Hello Akshay, in the controller function ( exports.uploads), when you are trying to catch the empty upload, I think it doesnt work because an empty array evaluates to a truthy value. At least on my end it was not working and I had to check the length. Cheers

    • @DailyTuition
      @DailyTuition  Před 2 lety

      Yes we have to check length. I think I forgot to add that in a hurry.

  • @nurettinsen473
    @nurettinsen473 Před 2 lety +1

    how to Get file name from base64 string , you did it for picture can we use it for files like pdf

  • @2ncielkrommalzeme210
    @2ncielkrommalzeme210 Před 11 měsíci

    wwith your video in my machine your code are not work hbs extension is correct. what you wrote.

  • @krishnavenil1814
    @krishnavenil1814 Před rokem

    hello sir,i wanted to implement this project but i am getting stuck in the display part 1:15:48

  • @gemorn
    @gemorn Před 2 lety

    i am gating TypeError: hbs is not a function

  • @athuynh8599
    @athuynh8599 Před 3 lety +1

    What if the image not string this is object contains 3 child object inside full, thumb and medium how can you do?

  • @shyamprakashm6325
    @shyamprakashm6325 Před 3 lety +2

    Will it work , when I use ejs instead of handle bars.?

    • @DailyTuition
      @DailyTuition  Před 3 lety

      Yes it is but you have to change some syntax

  • @sheldonfourie5959
    @sheldonfourie5959 Před 3 lety +1

    What about having the user build folders and move the files

  • @NEXEDU
    @NEXEDU Před 3 lety

    Sir please make best image search system for node.js important image from mongodb database

  • @parvejkhan4512
    @parvejkhan4512 Před 2 lety +1

    ITs show error when we uplaod image UploadModel is not a constructor , why its show

  • @rishidusad2985
    @rishidusad2985 Před 3 lety +1

    we are storing images in mongodb database in the end, so do we need multer anymore?

  • @xvset
    @xvset Před 3 lety +1

    Hey awesome video, but, i have a question, what if i want to make a button, that if you click it, it deletes the image or file

    • @DailyTuition
      @DailyTuition  Před 3 lety

      That's easy. Just delete the record from the database to do that

  • @realestatemanagementwebsit6971

    Hello, you did just great I appreciate it, but I have a question I am trying to use sharp to resize the images and change their formats the problem is that when I add it nothing happens can you help me with adding it to my project please?

  • @stephenyeboah3717
    @stephenyeboah3717 Před 3 lety +1

    Hello Sir that's a nice piece of video and very insightful. But can I save the images to cloudinary without saving them in the upload folder and still be saved in the database? I mean uploading multiple images. But I'm using React

    • @DailyTuition
      @DailyTuition  Před 3 lety

      Use image data hash value or image to store it in the database

    • @stephenyeboah3717
      @stephenyeboah3717 Před 3 lety

      @@DailyTuition Please I'm a bit new to these so could you please write a sample of the code for me please??

    • @stephenyeboah3717
      @stephenyeboah3717 Před 3 lety

      Can somebody please help to upload multiple images to mongodb database using cloudinary? I’m using react and nodejs as backend

  • @ramendrasoni3368
    @ramendrasoni3368 Před 2 lety +1

    I have a little problem....please resolve it.....i have made all this to backende with controller and gallery page name dgallery...and after that I want to display images from mongodb to frontend page named gallery page....so how can i achieve this...please help....

    • @DailyTuition
      @DailyTuition  Před 2 lety

      Store images in the mongo database. Fetch all the images and display it. But make sure you store images url instead of direct image.

  • @parvejkhan4512
    @parvejkhan4512 Před 2 lety +1

    hey i follow you video last two days its show error {"error":"Cannot Upload images.jpg Something Missing!"} how to fix it can you help me

    • @DailyTuition
      @DailyTuition  Před 2 lety

      This is user define message means the problem is in the try block. Try to read the complete error to solve this problem

  • @abhinandtp9048
    @abhinandtp9048 Před rokem

    If anyone having referenceError: uploads is not defined . Replace destination property by this piece of code. - destination: 'uploads'.

  • @hoangcuongtran4606
    @hoangcuongtran4606 Před 3 lety +1

    I'm working with mern i stuck on image upload to nodejs and serve that image back to client when i'm working with admin dashboard, now watching your video i know how to upload image, but how can i get those image and display back to product UI on react, on Mongo i'm only store file path to public folder in react folder ( react folder => root folder for front end, separate from backend folder which is for backend), never touch backend folder. Need your help please, thanks in advance for concerning my problem !

    • @DailyTuition
      @DailyTuition  Před 3 lety

      You have to identify the images path and create an api to fetch data. Use that api to get images from the database

    • @hoangcuongtran4606
      @hoangcuongtran4606 Před 3 lety +1

      @@DailyTuition first of all, thank you so much for the response, i really appriciate it, i'll note your solution. I find a way today may i ask you if its OK or not: in node server i serve images folder as static resources using express, and i've tried i can successfully get all the images in that folder which is completely outside of frontend folder. If this solution is not good, i'll switch to your way.

    • @DailyTuition
      @DailyTuition  Před 3 lety +1

      No. That's good

    • @hoangcuongtran4606
      @hoangcuongtran4606 Před 3 lety +1

      @@DailyTuition thank you my teacher !

    • @zainhaider1633
      @zainhaider1633 Před 3 lety

      @@hoangcuongtran4606 hey brother can you help me out with this. How to store and display multiple images in MERN please

  • @salekinimran7590
    @salekinimran7590 Před 3 lety +1

    @DailyTution I have an issue, My images are saved into mongoDB , but when tries to fetch, no image is shown
    . Could you help me?

    • @DailyTuition
      @DailyTuition  Před 3 lety

      Plz check your data of mongodb
      It may be missing

    • @kimmoramicky
      @kimmoramicky Před 3 lety +1

      use semi-colon (;) after contentType variable in index.hbs instead of colon(:). this was my mistake and it worked for me

    • @Lalit_Namdev
      @Lalit_Namdev Před rokem

      hello

    • @Lalit_Namdev
      @Lalit_Namdev Před rokem

      ​ I am facing this error when I upload images to the database == ​ "err": "cannot create a new collection -- already using 504 collections of 500"

  • @creative460
    @creative460 Před 3 lety

    I am first

  • @GamaIZing
    @GamaIZing Před 3 lety

    Hi, mate!
    I have problem with upload image into mongodb server. Locale alright, but then upload subsequent image error occurs. Apparently It 11000 error, cause i get error: `Duplicate ${files[index].originalname}. File Already exists! `. I tried with your github repository application, but it was same problem.
    Could your help me?
    Thanks.

    • @DailyTuition
      @DailyTuition  Před 3 lety

      I have a instagram Id akki.2013 message me there and send a close screenshot I will see you there

  • @datto0114
    @datto0114 Před 3 lety +1

    What if we want to upload just 1 image only

  • @tanzimibthesam5861
    @tanzimibthesam5861 Před 3 lety +1

    Awesome do you have plans on making videos on Nest.js

  • @Venkatesh-vm4ll
    @Venkatesh-vm4ll Před 3 lety +3

    sir can we use python Artificial intellegence in Node js,
    please reply me

  • @parvejkhan4512
    @parvejkhan4512 Před 2 lety +1

    app.engine('hbs',hbs({
    ^
    es/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47
    [nodemon] app crashed - waiting for file changes before starting...
    when we try its show same error how to resolve can you help me

    • @DailyTuition
      @DailyTuition  Před 2 lety

      Make sure you have hbs install in node module folder

    • @parvejkhan4512
      @parvejkhan4512 Před 2 lety +1

      thank for your response my bug is solve, if have any support system they will we contact us like any group and discord server,so provide us,they will be helpful for us

    • @DailyTuition
      @DailyTuition  Před 2 lety

      Don't have right now but soon it's available

  • @stalk3r928
    @stalk3r928 Před 3 lety +2

    Sir make this tutorial for ejs also please

  • @lalunacozumel
    @lalunacozumel Před 3 lety +1

    This is a very nice video, does someone know how to change also the text and not just the image?

    • @DailyTuition
      @DailyTuition  Před 3 lety +1

      I can help you

    • @lalunacozumel
      @lalunacozumel Před 3 lety +1

      @@DailyTuition thanks I just saw you comment, I'll contact you tomorrow thru Patreon, thanks.

    • @lalunacozumel
      @lalunacozumel Před 3 lety +1

      @@DailyTuition I send you a message trhu Patreon.

    • @DailyTuition
      @DailyTuition  Před 3 lety

      Let me check

  • @raymak8533
    @raymak8533 Před 3 lety +1

    hello sir,i wanted to implement this project using ejs but i am getting stuck in the display part 1:15:48 how can i use the (each image) and (each this) in ejs .please help and please try to give a code example

    • @DailyTuition
      @DailyTuition  Před 3 lety

      Should I make a ejs tutorial?

    • @raymak8533
      @raymak8533 Před 3 lety

      @@DailyTuitionit would be good but if you just provide the ejs code for the hbs files and pin it in the comment section it would be great as i have seen that many guys in the comments have the same issue.

    • @raymak8533
      @raymak8533 Před 3 lety

      @@DailyTuition it is an urgent issue so i think just the index.ejs code will be enough,as everything else is same and making a new video maybe time consuming for you

    • @DailyTuition
      @DailyTuition  Před 3 lety

      You have to convert the object in to json and use for loop to iterate over it. for(var i=0; i

    • @yashsavoicar491
      @yashsavoicar491 Před 6 měsíci

      @@DailyTuition
      Hi so i convert some aprt of ur code to ejs for displaying the images
      1)
      2)
      3)
      4)

  • @SonuSingh-qw2bs
    @SonuSingh-qw2bs Před 3 lety +1

    Instead of uploading the image to folder i want the image to be saved directly to the database how can i do it??

    • @DailyTuition
      @DailyTuition  Před 3 lety +1

      When you inspect the image src attribute you can find the image hash value or you can say image binary code. Use that to store image in the database

    • @SonuSingh-qw2bs
      @SonuSingh-qw2bs Před 3 lety +1

      @@DailyTuition so you're saying i don't have to put multer storage code i just have to put the code which I'll get at the time of posting and i can iteratie in the object and can find the image hash value and put it directly into the database??

    • @DailyTuition
      @DailyTuition  Před 3 lety

      Yes.

  • @venkatesh2788
    @venkatesh2788 Před 3 lety +1

    Will u make authentication system in jwt and also in passport js
    Please

    • @DailyTuition
      @DailyTuition  Před 3 lety

      I will upload that tutorial soon

    • @venkatesh2788
      @venkatesh2788 Před 3 lety +1

      @@DailyTuition your work is amazing, I understand everything, I need authentication video, thank you

  • @jenildesai9293
    @jenildesai9293 Před 2 lety +1

    I am getting an error TypeError: hbs is not a function

    • @DailyTuition
      @DailyTuition  Před 2 lety

      I think you are missing handlebar library. Make sure you add it

    • @gemorn
      @gemorn Před 2 lety

      bro tera problem solve huva ky

  • @sahadevdahit
    @sahadevdahit Před 2 lety +1

    Can we perform curd of image in mongo without storing in upload folder directly???

    • @DailyTuition
      @DailyTuition  Před 2 lety

      Yes. But that will increase the database size

  • @akshaysharma4270
    @akshaysharma4270 Před 3 lety +1

    🤓

  • @tsmmith9252
    @tsmmith9252 Před 3 lety

    sir please provide the ejs code for just the index hbs part

    • @stalk3r928
      @stalk3r928 Před 3 lety +1

      Yes sir this is very much needed .we are not being able to implement the (each) loop part in ejs .it would be wonderful if you comment the code and pin it in the comment section. We are all from the same college and tomorrow we have to submit this.

    • @raymak8533
      @raymak8533 Před 3 lety +1

      same problem sir pls provide the ejs code for index hbs

    • @DailyTuition
      @DailyTuition  Před 3 lety

      Guys. Convert the object onto json and use for loop to interate over it.
      for(var i=0; i

    • @tsmmith9252
      @tsmmith9252 Před 3 lety

      @@DailyTuition sir its again showing error

    • @tsmmith9252
      @tsmmith9252 Před 3 lety

      @@DailyTuition replace dot with .

  • @ryantheghost2185
    @ryantheghost2185 Před 3 lety +1

    first

  • @princeshalu
    @princeshalu Před 3 lety

    Hi
    I sent you some request on your mail. Can you plz reply me.
    Rajkumar

  • @twi4458
    @twi4458 Před 2 lety +1

    npm i express-handlebars
    npm ERR! code ETARGET
    npm ERR! notarget No matching version found for minimatch@^5.0.1.
    npm ERR! notarget In most cases you or one of your dependencies are requesting
    npm ERR! notarget a package version that doesn't exist.
    npm ERR! A complete log of this run can be found in:npm ERR! C:\Users\hp\AppData\Local
    pm-cache\_logs\2022-04-14T07_45_32_079Z-debug.log
    Im facing this issue while installing handlebars, Someone assist me pls.

    • @DailyTuition
      @DailyTuition  Před 2 lety

      Use this npm install express-handlebars

    • @twi4458
      @twi4458 Před 2 lety

      @@DailyTuition same error persists sir.

  • @abhinandtp9048
    @abhinandtp9048 Před rokem

    If anyone having referenceError: uploads is not defined . Replace destination property by this piece of code. - destination: 'uploads'.

  • @krishnavenil1814
    @krishnavenil1814 Před rokem +1

    hello sir,i wanted to implement this project but i am getting stuck in the display part 1:15:48