Tôi đang cố gắng tải lên tệp (ảnh) từ một ứng dụng mà tôi đang phát triển bằng Cordova (Phonegap), nhưng tôi luôn có được Error: Request Aborted
. Lúc đầu tôi đã sử dụng fs.readFile()
đó là điều đầu tiên mà tôi đọc, nhưng bây giờ tôi sử dụng Fomidable
nhưng lỗi là như nhau:NodeJs Tải lên tập tin Lỗi: Yêu cầu Hủy bỏ
Lỗi
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()
});
Để sao chép tệp, tôi đang sử dụng mô đun bổ sung fs. Tôi có thể làm gì ??
Bạn đã tìm thấy một giải pháp cho điều này? Tôi cũng nhận được lỗi tương tự. – detj