1 回答
TA贡献1829条经验 获得超6个赞
您只需要使用res.redirect('/path/here/);您的路线下的功能。
完整设置:
//Dependencies
const multer = require('multer');
//Multer DiskStorage Config
const diskStorage = multer.diskStorage({
destination: 'assets/profile_upload',
filename: (req, file, call_back) => {
//Prepend date to the filename or anything that makes
//the file unique so it won't be overwritten
call_back(null, Date.now() + '_' + file.originalname);
}
});
//Create Multer Instance
const upload = multer({ storage: diskStorage });
//Picture upload
//or app.post()
router.post('/upload-pic', upload.single('file'), (req, res) => {
//The redirection happens here.
console.log(req.file);
res.redirect('/your/path');
});
//Your code:
app.post('/upload', (req, res) => { ...
try doing app.post('/upload' ,upload.single('file'), (req,res) =>{ ...
添加回答
举报