richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

File is not created on server #249

Closed davvit closed 3 years ago

davvit commented 3 years ago

Upload seem to work but i dont see any file being created. The location of the server folder is desktop so its not restricted path. using VSCode in admin mode.

app.post('/upload', function (req, res) {

  if (!req.files || Object.keys(req.files).length === 0) {
    return res.status(400).send('No files were uploaded.');
  }

  // The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
  let sampleFile = req.files.file;

  //Use the mv() method to place the file somewhere on your server
  sampleFile.mv('./upload/test.png', function (err) {
    if (err)
      return res.status(500).send(err);

    res.send('File uploaded!');
  });
});

image

davvit commented 3 years ago

using the example in the example folder works...because it sets the uploadpath using __directoryPath

Example shown here is not complete https://github.com/richardgirges/express-fileupload/tree/master/example#basic-file-upload