我正在尝试在我的node/express应用程序中上传文件,但是我遇到了以下错误:
{ [Error: ENOENT, rename '/tmp/64124a9886fdb03f1faee159bc533776']
errno: 34,
code: 'ENOENT',
path: '/tmp/64124a9886fdb03f1faee159bc533776' }
/home/frankie/Projects/LP/routes/manager/deliverables.js:51
throw err;
^
Error: ENOENT, rename '/tmp/64124a9886fdb03f1faee159bc533776'
这是我应用程序中相关的代码:
if (req.files.file.name !== '' && req.files.file.size !== 0) {
// this will move the uploaded file from the tmp folder to the uploads folder
fs.rename(req.files.file.path, app.get('loc') + "uploads/" + name + "-" + id + "/" + req.files.file.name, function (err) {
if (err) throw err;
当我查看 /tmp 目录时,文件是存在的:
fiega@fiega:/tmp$ ll
total 56
drwxrwxrwt 12 root root 4096 Dec 12 11:33 ./
drwxr-xr-x 23 root root 4096 Sep 27 22:54 ../
-rw-rw-r-- 1 fiega fiega 903 Dec 12 11:33 13a26570f87297fd7f61785ef7d8772b
这就是我使用 body parser 的方法:
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
有什么想法吗?我尝试了更改整个应用的权限,但都没有效果。