You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// nodejsrouter.use('api/xxx/xx',function(req,res,next){utils.uploadFile(core.url,req)})// utils.jsvarformidable=require('formidable')varformData=require('form-data')varutils={uploadFile: function(url,req){// 这部分url的参数根据项目要求来lettag=req.qurey.tag// 用来标识这是个上传动作letmodule=req.qurey.module// 存储到数据库的哪个模块returnnewPromise(function(resolve,reject){varformfile=newformidable.IncomingForm()varformSubmit=newformData()formfile.parse(req,function(err,fields,files){req.body=fieldsreq.files=files// and so on 根据不同需求决定})})}}
先说说上传吧,上传主要是结合了前端WebUploader以及nodejs的formidable模块实现的,具体怎么实现下面细说吧。
1.上传
主要过程就是前端通过引入webUploader类来构造uploader对象,通过参数配置实现对接node层的处理上传的中间件。
The text was updated successfully, but these errors were encountered: