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

199
Views
Node.js uploaded file does not have path property

I am writing a file upload demo by multer in node.js.When form submit, I can get the file information, but it does not have path property.

ejs file

 <form method="post" enctype="multipart/form-data">
    <p>
        <input type="text" name="name" placeholder="name">
    </p>
    <p>
        <input type="file" name="photo">
    </p>
    <p>
        <input type="submit" value="Upload">
    </p>
</form>

js

function (req, res ,next) {
    var img = req.file;
    var name = req.body.name || img.originalname;
    var path = require('path').join(dir, name);
    console.log(img);
}

multer config

var multer = require('multer')();
app.post('/upload',multer.single('photo'),photos.submit(app.get('photos')));

req.file

enter image description here

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are using memStorage for storing file. That's why there is no path in req.file.

Try changing this to: var upload = multer({ dest: 'uploads/' }). Replace uploads/ with directory where you want to upload your file.

about 4 years ago · Santiago Trujillo Report
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!