我正在使用 express 处理 Node.js,我正在尝试上传图片
if(req.files.awatar.size > 0) {
var tmp_path = req.files.awatar.path;
var upload_path = USER_IMAGES+req.files.awatar.name;
fs.readFile(tmp_path, function(err, data) {
fs.writeFile(upload_path, data, function(err){
if(!err) awatar = req.files.awatar.name;
});
fs.unlink(tmp_path, function(){
if(err) throw err;
})
} );
}
但图像未上传,我在控制台上收到消息
.write(string, encoding, offset, length) is deprecated. Use write(string, offset, length, encoding) instead.