I want to read a file from a Windows file system or server so that I can display content on a website, and we are not allowed to use a database or just Javascript in PHP.
What I have now is below, and it works if I get the file from the boot box of the HTML file, the only thing I need is how to get the file in javascript without manually inserting it, and upload it to pageload.
The rest of the code works, if I insert the file manually, I only need to get the file and paste it into the var = file;
var file =
var reader = new FileReader();
reader.onload = function(progressEvent){
console.log(this.result);
var lines = this.result.split('\n');
for(var line = 0; line < lines.length; line++){
console.log(lines[line]);
}
};
reader.readAsText(file);
source
share