Closed dayney closed 4 years ago
What does that mean?
@dayney @RomanBurunkov I have the same error but after updating the path for the uploaded directory it's working fine
//before updating
sampleFile.mv(`../image/${sampleFile.name}`), function(err) {
console.log(err);
if (err) return res.status(500).send(err);
res.send("File uploaded!");
});
//after updating
sampleFile.mv(path.join(__dirname, `../image/${sampleFile.name}`), function(
err
) {
console.log(err);
if (err) return res.status(500).send(err);
res.send("File uploaded!");
});
//here the complete route
const path = require("path");
const uploadImage = app => {
app.post("/upload", function(req, res) {
if (!req.files || Object.keys(req.files).length === 0) {
return res.status(400).send("No files were uploaded.");
}
let sampleFile = req.files.doc;
sampleFile.mv(path.join(__dirname, `../image/${sampleFile.name}`), function(
err
) {
console.log(err);
if (err) return res.status(500).send(err);
res.send("File uploaded!");
});
});
};
Closing since no details provided.
I'm getting this error on mac as well. In my case (and might be the author's as well) this error occurs when the parent folder does not exist. Creating the bellow upload
folder solves the issue.
[Error: ENOENT: no such file or directory, open '/Users/<hidden>/uploads/581C050B-A9AE-4533-937C-FD87190E4B40.jpg'] { errno: -2, code: 'ENOENT', syscall: 'open', path: '/Users/<hidden>/uploads/581C050B-A9AE-4533-937C-FD87190E4B40.jpg' }
"errno": -2, "code": "ENOENT", "syscall": "open",