module.exports = {
index: function (req,res){
res.writeHead(200, {'content-type': 'text/html'});
res.end(
'<form action="http://localhost:1337/product/upload" enctype="multipart/form-data" method="post">'+
'<input type="text" name="title"><br>'+
'<input type="file" name="avatar" multiple="multiple"><br>'+
'<input type="submit" value="Upload">'+
'</form>'
)
},
upload: function (req, res) {
//打印出请求过来的所有东西,都没有发现文件名。。
console.log(req);
return;
req.file('avatar').upload(function (err, files) {
if (err)
return res.serverError(err);
return res.json({
上传成功了是有文件名,但是上传前先获取文件或,判断,再限制上传不是很好吗?
message: files.length + ' file(s) uploaded successfully!',
files: files
});
});
}
};
到底怎么获取文件名啊?