Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,740 members, 7,817,042 topics. Date: Saturday, 04 May 2024 at 12:36 AM

File Upload With Multer In Node.js And Express - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / File Upload With Multer In Node.js And Express (221 Views)

Confused Between Node Js And PHP / How Can I Post Multiple Files Using Multer In Node Js / Image Upload In Mongodb And Nodejs With Multer Doesn't Work After Hosting The Ap (2) (3) (4)

(1) (Reply)

File Upload With Multer In Node.js And Express by robertlook2020: 4:21am On Apr 12, 2021
In this tutorial, we are going to learn how to upload images on the server with multer and express in Node.js. File upload is a common operation for any project. Node.js with the Express Web Framework and the multer Library, this tutorial we adding a file upload feature to your app is very easy. You will learn in this tutorial to make you comfortable in building apps that can easily handle any file uploads.

* We will be covering the following topics:
* What is Multer?
* Project Setup
* Adding Multer
* Disk Storage

https://www.phpcodingstuff.com/blog/file-upload-with-multer-in-nodejs-and-express.html

![This is image title](https://www.phpcodingstuff.com/uploads/tutorial_images/File_Upload_with_Multer_in_Node_js_and_Express1.jpg "This is image title"wink

Adding Multer

`npm install multer --save`



const multer = require('multer');
const upload = multer({dest:'uploads/'}).single("demo_image"wink;


The following code will go in app.js:


app.post("/image", (req, res) => {
upload(req, res, (err) => {
if(err) {
res.status(400).send("Something went wrong!"wink;
}
res.send(req.file);
});
});


Original Source :https://www.phpcodingstuff.com/blog/file-upload-with-multer-in-nodejs-and-express.html

(1) (Reply)

How To Convert MP4 To AVI Online / Software Development Tools That Boost Our Productivity / Software For Data Capture With Digita Persona Scanner

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 7
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.