,

Express js के लिए शुरुआत करने वालों के लिए ट्यूटोरियल (2024) हिंदी में, फाइल अपलोड करें, Multer #nodejstutorial #expressjs

Posted by

Express js tutorial for beginners in hindi 2024

Express js tutorial for beginners in hindi 2024

Express.js is a popular web application framework for Node.js. It allows you to build web applications quickly and efficiently. This tutorial will help beginners learn how to use Express.js in Hindi in 2024.

Upload File using Multer

Multer is a middleware for handling file uploads in Node.js. It makes it easy to upload files to your server. Here’s how you can use Multer with Express.js:

Step 1: Install Multer

First, you need to install Multer using npm. Run the following command in your terminal:

npm install multer

Step 2: Use Multer in your Express.js app

Once Multer is installed, you can use it in your Express.js app. Here’s an example of how to upload a file using Multer:

        const express = require('express');
        const multer = require('multer');
        const app = express();
        
        const storage = multer.diskStorage({
            destination: function (req, file, cb) {
                cb(null, 'uploads/')
            },
            filename: function (req, file, cb) {
                cb(null, file.originalname)
            }
        })
        
        const upload = multer({ storage: storage })
        
        app.post('/upload', upload.single('file'), (req, res) => {
            res.json({ message: 'File uploaded successfully' });
        })
        
        app.listen(3000, () => {
            console.log('Server started on http://localhost:3000');
        })
    

With this code, you can upload a file to the server by sending a POST request to the /upload endpoint with a file field in the request body.

Conclusion

In this tutorial, we learned how to use Multer to upload files in an Express.js app. Multer is a powerful tool that makes handling file uploads easy. I hope this tutorial was helpful for beginners learning Express.js in Hindi in 2024.

0 0 votes
Article Rating
8 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@Itanddccom
4 months ago

Very nice

@user-kd7fw7ki1d
4 months ago

nice content sir…kindly please finish this playlist sir…waiting to complete….thank you in advance 🙏

@shishirsharma-ut1bb
4 months ago

Thanks for uploading this video

@prabhasharma5461
4 months ago

Plz sir next video code de do

@shrikantkajale3047
4 months ago

sir github link kaha hai ?

@prabhaseoexpert2013
4 months ago

Wow nice

@musicmasti1455
4 months ago

@videomaker8728
4 months ago

Thanks for upload this video