Skip to content

Commit

Permalink
Merge pull request #255 from brettjouwstra/master
Browse files Browse the repository at this point in the history
Changed example
  • Loading branch information
richardgirges authored Jan 11, 2021
2 parents 2d6cad9 + d5f884a commit 1836b58
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ const app = express();
app.use(fileUpload());

app.post('/upload', function(req, res) {
let sampleFile;
let uploadPath;

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.sampleFile;
sampleFile = req.files.sampleFile;
uploadPath = __dirname + '/somewhere/on/your/server/' + sampleFile.name;

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

Expand Down

0 comments on commit 1836b58

Please sign in to comment.