0
我有一個代碼:的fs readFilesync錯誤路徑必須是上傳文件 這裏的代碼串
var oriPath = JSON.stringify(req.files.profilePicture);
var data = fs.readFileSync(oriPath.path);
var ext = path.extname(oriPath.name);
if (!ext) {
return next(err);
}
var newName = Date.now().toString() + ext;
var path = config.fullhostname + config.uploadDir + newName;
if (!fs.writeFileSync(path, data)) {
return next("Failed to upload image", 400)
}
和示值誤差這樣的:uncaughtException TypeError: path must be a string
指var data = fs.readFileSync(oriPath.path);
但文件表被成功上傳,如何解決這個問題?謝謝