0

I need my website to save basic text to a .txt file located in the server. Using PHP is not a option because the site is hosted on Google Drive which does not support PHP.

So for testing purposes I want to create a button and when you press it, it will write "something 123" to a .txt file located in the server.

Using jQuery I managed to LOAD text from a .txt file so surely saving is possible as well?

This is what I used to load text from a .txt file and it worked perfectly

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#LOAD_TEXT_HERE").load("test.txt"); //This is the .txt file located in the server
});
</script>

How can I write text to this same file using jQuery? (or using other methods?)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
htmlcoder123
  • 355
  • 2
  • 4
  • 7
  • 2
    possible duplicate of [Read/write to file using jQuery](http://stackoverflow.com/questions/582268/read-write-to-file-using-jquery) – Artur Filipiak Sep 22 '15 at 17:27
  • Unless you use some Google Drive API to send an updated file, you can't use jQuery on its own to modify anything on the server. – Rashad Nasir Sep 22 '15 at 17:28
  • not possible! security risk! if JavaScript can write to server, i can just pop a script and hack the server from my own browser! – cylua2 Sep 22 '15 at 17:28
  • You need something on the server side to write on that txt file...if you can't do it with server side language, maybe you can accomplish such task via google drive api. – Hackerman Sep 22 '15 at 17:29
  • Do you have any idea how to do this via google drive api, I've been searching from the google drive api site but can't really find the thing I'm looking for – htmlcoder123 Sep 22 '15 at 18:03
  • LocalStorage with modern browser will be a good choice – A l w a y s S u n n y Sep 22 '15 at 18:23
  • If it were me I'd write a PHP script that writes to the file and I'd call it via AJAX. Though you'd definitely want to lock that file down to prevent unauthorized writes. – Sabrina Nov 02 '15 at 21:01

0 Answers0