When I upload a folder, it will only get the actual files within the folder instead of the folder aswell? Is it possible to get the folder and then inside that the files?
router file:
// upload files to user's account
router.post('/upload', ensureAuthenticated, (req, res) => {
if (!req.files || Object.keys(req.files).length === 0) {
return res.status(400).send('No files were uploaded.');
}
// Find where to place the file
const sampleFile = req.files.sampleFile;
console.log(sampleFile);
const path = req.body['path'];
const directPath = path.split('/').slice(2, path.length).join('/');
const newPath = location + req.user._id + '/' + directPath + '/' + sampleFile.name;
// save file
sampleFile.mv(newPath, function(err) {
if (err) return res.status(500).send(err);
res.redirect('/files/' + directPath);
});
});
When I upload a folder, it will only get the actual files within the folder instead of the folder aswell? Is it possible to get the folder and then inside that the files?
router file:
webpage file (.ejs):