java 文件上传终止_NodeJs上传文件错误:请求已中止

我和Cordova(Phonegap)一起开发,但我总是获得 Error: Request Aborted . 一开始我使用 fs.readFile() 这是我读的第一件事,但现在我使用的是 Fomidable ,但错误是一样的:

Error

Error: Request aborted

at IncomingMessage.onReqAborted (../XAMPP/xamppfiles/htdocs/nodeyag/node_modules/express/node_modules/connect/node_modules/multiparty/index.js:131:17)

at IncomingMessage.EventEmitter.emit (events.js:117:20)

at abortIncoming (http.js:1912:11)

at Socket.serverSocketCloseListener (http.js:1924:5)

at Socket.EventEmitter.emit (events.js:117:20)

at TCP.close (net.js:466:12)

/picUpload

var form = new formidable.IncomingForm();

form.parse(req,function(err,fields,files) {

if(err) console.log(err);

console.log(files);

});

form.on('end',function(fields,files) {

// temporary location of the uploaded file

var tempPath = this.openedFiles[0].path;

// filename of the uploaded file

var fileName = this.openedFiles[0].name,

newPath = config.uploadPicsDir + '/docs/';

var file = { tempPath: tempPath, fileName: fileName };

console.log(file);

fs.copy(tempPath, newPath + 'picture.jpg' , function(err) {

if(err) return next(err);

console.log("file success!");

res.send('Ok');

});//end of copy()

});

为了复制文件,我正在使用模块fs-extra . 我能做什么??

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值