Im using the following code to read simple file from my desktop
module.exports = function (app) {
app.get('/aa', function(req, res) {
fs = require('fs');
fs.readFile('C:\\Users\\t56789\\Desktop\\myfile.txt', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
console.log(data);
res.send(data);
});
});
when I hit in the browser /aa i got the following error
{ [Error: ENOENT, open 'C:\Users\t56789\WebstormProjects\Ro0.1\?C:\Users\t56789\Desktop\myfile.txt']
errno: -4058,
code: 'ENOENT',
path: 'C:\Users\t56789\WebstormProjects\Ro0.1\?C:\Users\t56789\Desktop\myfile.txt' }
if I return instead res.send("test") i able to see in the browser test...
any idea what I miss here ?
c:/myWebsite, Node will only be able to read what is insidec:/myWebsite. Only your website's files, not the whole disk. Unless I'm mistaken.