不知道有哪些情况会导致files为空,fields 有值, 值为 {upload: 'test.png'}, test.png就是我上传的那张图片,请大家帮我看看,不甚感激
var form = new formidable.IncomingForm();
form.parse(request, function (error, fields, files){
console.log(files);
fs.renameSync(files.upload.path, 'temp/test.png');
response.writeHead(200,{'Content-Type': 'text/html'});
response.end('<img src="/show">');
});
伊谢尔伦2017-04-17 12:03:59
https://cnodejs.org/topic/50234890f767cc9a51f88481
This post may have what you need, I also encountered such a problem
PHPz2017-04-17 12:03:59
If you are learning from this website www.nodebeginner.org/index-zh-cn.html:
You should just comment out the following line of code in sever.js
request.setEncoding(" utf8");