我很茫然,最近我的快递 4 应用程序已经停止上传。任何上传文件的尝试都会导致“上传:0%”,它只是挂在那里,下面的事件都没有触发,所以我什至不会收到错误。
router.post('/uploader', function(req, res){
var form,realFileName;
form = formidable.IncomingForm();
form.uploadDir = path.join(__dirname, '../' + opts.uploadDir);
form.maxFieldsSize = 1000 * 1024 * 1024;
form.keepExtensions = true;
form.type = 'multipart';
form.on('fileBegin', function(err, file){
file.path = form.uploadDir + "/" + file.name;
realFileName = file.name;
});
form.on('file',function(name, file){
});
form.on('error', function(err){
res.render('uploader',{title: 'Upload Error'});
});
form.on('end', function (err, file){
res.render('uploader',{title: 'Upload Success'});
});
//res.render('uploader',{title: 'Upload Success'});
});
形式:
<form action="/uploader" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="104857600">
<input type="file" name="uploadCsv">
<input type="submit" value="Upload CSV">
</form>