File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,19 @@ const app = express();
1111app .use (fileUpload ());
1212
1313app .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
You can’t perform that action at this time.
0 commit comments