node.js上传图片,图片上传不完整,请帮忙解决。
用的代码很简单:
app.use(express.bodyParser({
uploadDir:__dirname + '/uploadfile/group/icon',
keepExtensions:true,
defer:true, //enable event
limit:10000000
}));
app.disable("multipart");
app.post('/upload',function(req, res){//bind event handler
req.form.on('progress',function(bytesReceived, bytesExpected){
console.log(((bytesReceived / bytesExpected)*100)+"% uploaded");});
req.form.on('end',function(){
console.log(req.files);
res.send("done");});
});
但是上传后发现有的图片完整上传,有的不完整,对比如下:
而且奇怪的是bytesReceived竟然比bytesExpected还要大。。
4 回复
知道了,是app.disable(“multipart”);这里的问题,去掉就正常了,具体原因得再看看了
我实现了一个多图上传的,http://www.9958.pw/post/nodejs_upload_images
好东西啊