简体   繁体   中英

Open, edit and save a text file using XMLHttpRequest and javascript

i need to update a text file in my website, i need to open it then view that text then retype the text on it it and then save it back to the server.

i am able to open the file using XMLHttpRequest, i can view the text on the file, now i need to over write the text on that file with text that i would input from a webpage, how can i do that using javascript and XMLHttpRequest? thanks.

In addition you need a serverside service (ASP.Net / PHP etc.) to handle the file IO, its a good thing this can't be done by just Javascript and XMLHttpRequest

Unfortunately, you cannot do that with only the JavaScript technology. You will have to use another technology in order to write to your file.

You can use PHP for instance and use the

fwrite($fp, "The text coming from XMLHttpRequest");

method ( http://www.php.net/fwrite )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM