I have on my web server a JS script that I want to be able to read files. My filesystem is like this:
> Root
index.html
read.js
> files
file.txt
In this example, the file "file.txt" will contain the simple word "Hello"
With JavaScript, I wish to be able to make a function, for example:
function read (path) {
//Stuff to read the file with specified path
var content = //whatever the content is
return content;
}
And then be able to call it with:
var file = read("/files/file.txt")
And then when I do
alert(file)
It will pop up with/alert you with "Hello", the content of file.txt.
Is there any way that I would be able to do this?