求教大牛,我想从onFileUploadComplete 传数据到后面的function,如何做到? 或者,如何在onFileUploadComplete 里面,使用req.end()?
- express 4.11.1
- multer 0.1.6
var mwMulter1 = multer({ dest: 'public/images/uploads/', rename: function(fieldname, filename){ console.log('new rename,filename is:',filename); return filename + Date.now(); }, onFileUploadComplete: function (file) { done = true; var t = Date.now(); } }); app.post('/upload',mwMulter1, function(req, res, next){ var id = 'ckeditor_src'; var t = t// 我想从onFileUploadComplete 里面获得 t 变量 res.end('t is:'+t); });
3 回复
onFileUploadComplete()
函数完整参数版是:onFileUploadComplete(file, req, res)
,你可以直接在这里拿到res
,req
的,做能做的各种操作。。所以也可以通过如向req.files
,req.body
这些里挂属性往后面的回调里传你想传的数据
https://github.com/expressjs/multer#onfileuploadcompletefile-req-res