[英]new File() gives me undefined File in javascript nodejs
我正在尝试使用以下代码打开本地文件并从图像文件创建File
对象
var newFileObj = new File([buffer],fileObj.originalname,{type: fileObj.mimetype});
但是这给我File是不确定的。 我正在使用nodejs v7.0.0
使用文件类型之前,我需要任何文件吗?
PS-这是REST API,不包含html。
您需要在节点环境中使用“ fs”读取/写入文件。 链接在这里
https://nodejs.org/api/fs.html
fs.open('myfile', 'r', (err, fd) => {
if (err) {
if (err.code === 'ENOENT') {
console.error('myfile does not exist');
return;
}
throw err;
}
readMyData(fd);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.