/文件上传模块编码缩写/ app.post(’/file-upload’,function(req,res){ var tempPath=res.files.thumbnail.path; var target_path = ‘./public/images/’ + req.files.thumbnail.name; fs.rename(tempPath,target_path,function(err){ if (err) throw err; //del fs.unlink(tempPath,function(err){ if(err){ throw err; } res.send(‘File uploaded to: ’ + target_path + ’ - ’ + req.files.thumbnail.size + ’ bytes’); }) }); })
编译器报这个错,请教是啥问题呢: events.js:71 throw arguments[1]; // Unhandled ‘error’ event ^ Error: ENOENT, open ‘F:\wwwroot\weibo_vite\demo\nodejs\expressTest\uploads\b25e6d4d6868e039b3dd6db73c86b0eb’
Process finished with exit code 1
因为rename已经把缓存图片删除了,所以就不用fs.unlink了, 你把fs.unlink的代码注释就OK了
是的,我今天也遇到了,用的express3.x的版本,也报这样的错,后来把unlink去掉就好了
win7下提示
if (err) throw err;
^
Error: EXDEV, rename 'd:\Temp\bfab3fa0b7542ae1643cfdb788ee0fa1'
另外
var tempPath=res.files.thumbnail.path; 应该是req