Nik P
Nik P

Reputation: 7

How can you read, write, and create ".txt" files using Javascript?

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.

Upvotes: 0

Views: 960

Answers (4)

Gneccao
Gneccao

Reputation: 1

Impossible, only server-side languages

Upvotes: 0

wassup
wassup

Reputation: 2511

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.

Upvotes: 0

Joe
Joe

Reputation: 15812

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.

Upvotes: 0

Gustav Westling
Gustav Westling

Reputation: 633

No. You can't. For this you will need backend server software, like PHP.

Upvotes: 1

Related Questions