Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
Buffer object in req.file is coming undefined in express.js

Form in frontend React.js.

const handleUpload = (e) => {
    setFormvalue({ ...formvalue, recevierImages: e.target.files[0] });
  };

  const submitData = () => {
    console.log(formvalue);
    dispatch(createDonation(getFormData(formvalue)));
  };

   <Form>
     <Form.Item name="donationImage" label="Upload Image">
        <input type="file" onChange={(e) => handleUpload(e)} />
      </Form.Item>
   </Form>
   <Button onClick={submitData} type="primary">
      Create
    </Button> 

recevierImages is the name were image is stored in react and on click of submitData all the data is appended to FormData and send to express js

api in backend express.js

const express = require("express");
const multer = require("multer");

const donationController = require("../controller/donationController");

const router = express.Router();

const multerStorage = multer.diskStorage({
  destination: function (req, file, callBack) {
    callBack(null, "");
  },
});

const uploadImage = multer({ storage: multerStorage }).single("recevierImages");

router.post("/create", uploadImage, donationController.createDonation);
router.patch("/update", donationController.updateDonation);

module.exports = router;

donationController.js

const createDonation = async (req, res) => {
  try {
    console.log(req.file.buffer);
  } catch (error) {
    console.log(error);
    res.status(500).send(error);
  }
}

module.exports = {
  createDonation,
};

In donationController.js req.file.buffer is undefined

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!