Reputation:
I am trying server-side js injection for my assignment. I am able to find the directory names using the command:
res.end(require('fs').readdirSync('.').toString())
output:
photos,practice.db,public,routes,fun,server.js,views
Now I want to look inside the 'fun' directory and read it's file content. I tried:
res.end(require(‘fs’).readFileSync(‘fun’))
but it's not working because it's a directory.
Upvotes: 1
Views: 448
Reputation: 7403
How about this?
res.end(require('fs').readdirSync('./fun').toString())
The code you're trying is using readFileSync
instead of readdirSync
.
Upvotes: 1