multer/express/node.js图片上传实例
2021-06-16 01:03
let multer = require(‘multer‘) let storage = multer.diskStorage({ destination : (req,file,cb)=>{ //保存在public文件夹的upload文件夹里 cb(null,path.join(__dirname, ‘../public/upload/‘)) }, filename:(req,file,cb)=>{ cb(null,file.originalname) } }) let upload = multer({ storage: storage }) router.post(‘/‘, upload.single(‘avatar‘), function (req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.send({ code: 1, message: ‘successs‘ }) })
上一篇:Jquery滚动监听和附加导航
下一篇:PHP
文章标题:multer/express/node.js图片上传实例
文章链接:http://soscw.com/essay/94359.html