Skip to content

Commit 1836b58

Browse files
Merge pull request #255 from brettjouwstra/master
Changed example
2 parents 2d6cad9 + d5f884a commit 1836b58

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

example/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ const app = express();
1111
app.use(fileUpload());
1212

1313
app.post('/upload', function(req, res) {
14+
let sampleFile;
15+
let uploadPath;
16+
1417
if (!req.files || Object.keys(req.files).length === 0) {
1518
return res.status(400).send('No files were uploaded.');
1619
}
1720

1821
// The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
19-
let sampleFile = req.files.sampleFile;
22+
sampleFile = req.files.sampleFile;
23+
uploadPath = __dirname + '/somewhere/on/your/server/' + sampleFile.name;
2024

2125
// Use the mv() method to place the file somewhere on your server
22-
sampleFile.mv('/somewhere/on/your/server/filename.jpg', function(err) {
26+
sampleFile.mv(uploadPath, function(err) {
2327
if (err)
2428
return res.status(500).send(err);
2529

0 commit comments

Comments
 (0)