Giter Site home page Giter Site logo

Comments (5)

Doc999tor avatar Doc999tor commented on April 28, 2024

You didn't attach the specific error you got, but as far as I can see:

  1. the row const { image = '' } = req.body; and returning 400 might be not necessary
  2. since you already handle the image field in the request by the if (!req.file) {
  3. Middleware upload.single('image') will take the image field from the body and populate the req.file

from multer.

barbiedo avatar barbiedo commented on April 28, 2024

This is the error of my code, i don’t know what is the wrong of code.

IMG_9989

from multer.

barbiedo avatar barbiedo commented on April 28, 2024

IMG_9985

from multer.

jha-adrs avatar jha-adrs commented on April 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.