I am writing a website and I have a very basic understanding of JavaScript (JS) but a good understanding of HTML and CSS. I want to have an admin part of the website were you can edit the content of the site. I also need help on how to display these text files onto the website using JS. Thank you for your help.
-
standard JS has no file operations whatsoever. there's web storage, but that's not what you're looking for.Marc B– Marc B2012-11-05 18:52:46 +00:00Commented Nov 5, 2012 at 18:52
-
Do you have a back end? What is your backend language?gbtimmon– gbtimmon2012-11-05 18:52:51 +00:00Commented Nov 5, 2012 at 18:52
-
2JavaScript cannot write to the local filesystem. You can use Ajax to post data to the server and save the values on the server.gpojd– gpojd2012-11-05 18:52:51 +00:00Commented Nov 5, 2012 at 18:52
-
Since the file is in the server, it should be handled by server side scripts. JavaScript (the client side) should only manipulate data retrieved from the server and then upload it.Jay– Jay2012-11-05 19:21:56 +00:00Commented Nov 5, 2012 at 19:21
Add a comment
|
4 Answers
You can do it with ActiveX objects - http://www.yaldex.com/wjscript/jsfilecreateTextFile.htm - but you're tying yourself to proprietary IE support.
Other than that, you'll need a server-side language such as PHP.
Comments
In HTML5 you can operate on local files via the File API (have a look at http://www.html5rocks.com/en/tutorials/file/dndfiles/ for a quick tutorial) but manipulating files on the server using JavaScript on its own is impossible. You need to use AJAX to send a request to a PHP (or some other server-side language) script to do it for you.