1
這裏是我的代碼:EPERM使用錯誤fs.rename()
exports.post_handler = function(req, res) {
var photo = req.files.image;
console.log(photo);
console.log(__dirname);
fs.readFile(photo.path, function(err, data) { //I use the path module to join the image path strings
fs.rename(path.join(__dirname, "public/temp"), path.join(__dirname,"public/images"), function(err) {
if (err) {
console.log(err);
res.redirect("/");
}
else {
console.log("file " + photo.name + "written to uploads folder");
res.redirect("/home");
}
});
});
}
我想從我的temp
文件夾移動上傳的圖片文件到我的uploads
文件夾。我正在使用fs
模塊來做到這一點。我的電腦上授予完全權限這兩個文件對所有用戶後,我發現了以下錯誤:
{ [Error: EPERM, rename 'dir\public\temp']
errno: 50,
code: 'EPERM',
path: 'dir\\public\\temp' }
我不知道發生了什麼事情錯在這裏。有人有主意嗎?