Comments (5)
You didn't attach the specific error you got, but as far as I can see:
- the row
const { image = '' } = req.body;
and returning 400 might be not necessary - since you already handle the
image
field in the request by theif (!req.file) {
- Middleware
upload.single('image')
will take theimage
field from the body and populate thereq.file
from multer.
This is the error of my code, i don’t know what is the wrong of code.
from multer.
from multer.
I am having a error too, I dont understand what I am doing wrong
Error:
Error: ENOENT: no such file or directory, open 'C:\Users.......src\routes\uploads\product_file-1693576521663.xlsx'
const path = require('path');
const multer = require('multer');
let storage = multer.diskStorage({
destination: function (req, file, cb) {
// Create the uploads folder if it does not exist
if (!fs.existsSync('./uploads')) {
fs.mkdirSync('./uploads');
}
cb(null, './uploads/');
},
filename: function (req, file, cb) {
let datetimestamp = Date.now();
cb(null, file.fieldname + '-' + datetimestamp + '.' + file.originalname.split('.')[file.originalname.split('.').length - 1]);
}
});
const upload2 = multer({
storage: storage,
});
const upload = multer();
routes.post('/product-file-upload',upload2.single('product_file'),require('../controllers/products/updateSwagProducts'));
//routes.post('/product-file-upload',upload.single('product_file'),require('../controllers/products/updateSwagProducts'));
The file contents are coming through the request but I somehow cant save it, even though I have created the uploads folder
from multer.
Related Issues (20)
- Why Postman filename is right, but in the web I use formdata.append() the filename is rong? HOT 1
- ERROR UPLOADING FILE
- Translation of Documentation to Indonesian
- Multer gives error on serverless if using without express js
- Error in uploading a photo in javascript using a multer. HOT 2
- There is a way to effectively add a custom Error handler to multer? HOT 2
- (love) Just to tell you how great your software is HOT 1
- TypeError: Cannot read properties of undefined (reading 'length') when fieldNameSize is not set HOT 6
- Upgrade to the latest version of busboy to prevent potential DOS attack via Dicer HOT 1
- File upload got stuck while uploading large text files HOT 3
- Upload file use Multer with Multer-gridfs-storage in environment of bun is not working but when I use environment of nodejs then it's working? HOT 1
- req.file returning Undefined on frontend, but with Insomnia returns correctly HOT 4
- Custom storage engine not working
- MulterError: Unexpected field when trying to use different storage configuration HOT 1
- Update Docs: Error: read ECONNRESET thrown during test using supertest, mocha but works fine while using postman. HOT 1
- Why does Multer does not release memory? HOT 1
- `preservePath` option not respected HOT 2
- This module only works with node 14 or LOWER HOT 39
- file.size undefined with multiple files HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multer.