I also discovered this problem. Multer was uploaded directly. It has a separate event, but it seems to be difficult to use.
This is what I wrote
coffeescript body = req.body
path = res.locals.Path
f = req.files.uploadpic
if not f? or f is ""
return res.send new helper.recode(201,"请指定上传的图片")
console.log oldname
console.log body,path
console.log req.files
console.log f
location = __dirname+"/../../public/uploadDir"
oldname = location+"/"+f.name
if not body.album? or body.album is ""
fs.unlink oldname, (err)->
res.send new helper.recode(201,"相册 ID 不能为空")
return false
if not body.token? or body.token is ""
fs.unlink oldname, (err)->
res.send new helper.recode(201,"您还没有登录,请先登录")
return false
if not res._user? or res._user is ""
fs.unlink oldname, (err)->
res.send new helper.recode(201,"您还没有登录,请先登录")
return false
If the token is incorrect, delete the obtained image or file.
If the token check is OK, just rename the uploaded file.
I also discovered this problem. Multer was uploaded directly. It has a separate event, but it seems to be difficult to use.
This is what I wrote
If the token is incorrect, delete the obtained image or file.
If the token check is OK, just rename the uploaded file.