0
if (sess.username) {
var form = new formidable.IncomingForm();
form.multiples = true;
form.uploadDir = __dirname + "/data";
form.parse(req, function (err, fields, files) {
if (fields.title.length < 120 || fields.content.length < 1000000) {
var articleData = new articleModel({
title: fields.title,
content: fields.content,
created_at: Date.now()
});
articleData.save(function (err) {
console.log('saved');
});
form.on('error', function (err) {
console.log('An error has occured: \n' + err);
});
}
else {
res.render('failed', {
message: 'Too much characters.'
});
}
});
res.redirect('/admin');
}
我與此代碼嘗試,但我得到的錯誤是這樣的:和的NodeJS厲害,上傳圖片
Error: ENOENT: no such file or directory, open 'C:\Users\Użytkownik\Documents\GitHub\CFBlog\controllers\admin\data\upload_c2aff6d1c5930dd655caa436890aaf03' at Error (native)
歡迎來到Stack Overflow!您可以先[參觀](http://stackoverflow.com/tour)並學習[如何提出一個好問題](http://stackoverflow.com/help/how-to-ask)並創建一個[最小,完整和可驗證](http://stackoverflow.com/help/mcve)示例。這使我們更容易幫助你。 –