Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  128] [ 3]  / answers: 1 / hits: 25337  / 13 Years ago, mon, february 27, 2012, 12:00:00

I want to create a simple game in HTML5/JS and I don't want the user to run any webserver or to have to connect to a website. (just an HTML page)



But it looks like FileReader can only be used on files type inputs.



Is it possible to have only two files : index.html and foo.txt side by side and to read foo.txt from index.html with something like :



// No input needed, I know waht I want to read
var my_file = new File(foo.txt);
var reader = new FileReader();
alert( reader.readAstext( my_file, UTF-8 ) );


Any idea ?


More From » html

 Answers
7

I believe that this is your answer: How to open a local disk file with Javascript?



In short, you are looking something like this:



<input type=file id=files name=file />


HTML5 allows you to load files which are stored locally on computer, but you cannot select it. User must select file which he/she wants to be loaded.



Just imagine what would happen when developers (or better spoken, hackers) would have access to everyones local data...


[#87173] Sunday, February 26, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jacie

Total Points: 490
Total Questions: 111
Total Answers: 105

Location: Mali
Member since Sat, Feb 12, 2022
2 Years ago
;