File/Image Upload With Multer in Node js and Express

File/Image Upload With Multer in Node js and Express

Today, in this article, we will explain to you how to file/image upload with multer in node js and Express. so in this example, we are using the multer npm package for image upload in node js. we can easily image or file upload using multer in node js.

What is multer in node JS?

A multer is one type of npm package and it is a Node.js middleware for handling files. it is used to file uploading in node js.

So you can follow the below step for node js multer file upload example.

Step 1: Create the Application Directory.
First, we will open the command prompt and create the application directory in our directory. for this, you can follow the below command.

Step 2: Install node js packages
In this step, we will create a package.json file in your application directory and paste the below code in this file.

now, you can run below command for install packages.

Or, You can also install using the following command

Step 3: Create Server file
we will create a server.js file in your application directory and paste the below code in this file. here we will load the npm package.

Step 4: Create the view file and upload directory
In this step, we will create the index.html file for the upload of the image and create the uploads directory.
index.html

Step 5: Run Application
Now, you can run your application following Url.

Please follow and like us: