+ 4
Reading / uploading file on web page
I want user to input a text file from his local storage to browser , then i want to read that file using JavaScript. how to do this? what should i learn ? can you explain with simple example? This is what I want to achieve 1> User selects a text file from his storage device 2> Read , verify and do some string operations on file using JAVASCRIPT 3> Create a JSON object by extracting text from file 4> Send JSON to server
11 odpowiedzi
+ 6
You need server side scripts.
You need a web server to run your project. Why not use php instead.
+ 4
I can run nodejs server locally
+ 4
This is what I want to achieve
1> User selects a text file from his storage device
2> Read , verify and do some string operations on file using JAVASCRIPT
3> Create a JSON object by extracting text from file
4> Send JSON to server
+ 4
ok thanks @Morpheus
I found something here :-
https://www.html5rocks.com/tutorials/file/dndfiles/
+ 3
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data
I have not done this yet but I ll try it myself too 👍
I ll post the progress soon
+ 3
code learner , do you want to modify the file locally as well before converting it to json,
I have few codes for that on nodejs,
fs module will handle that file manipulation,
rest JSON.stringify() and a post Operation will take care , I ll try to write it fresh with comments 👍
+ 3
ok
+ 2
code learner I made the complete stuff , i ll post the repo link ,
sorry for delay but using npm packages for everything made me so ignorant that I had to study again fir doing simple things, like request handling , body parsing etc 😅
+ 1
yes html5 s file reader API , its awesome 👍
+ 1
so , I m still trying to parse the post body at server side without any external libraries,
hence you ll get clumsy raw data, will update the repo as I find a fix