How?
Acoder, as usual, is correct. JavaScript is a client side language. Meaning it runs on the client, in this case the browser. It can not write to disk on a remote server. It can not even run on the server. HTML and or JavaScript can be used to send a file to the server, but you would need server side code there to receive it and write it to disk for you.
If you know of some way around this we are all ears.
[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>javascript-only file writing</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>javascript fileIO demo</h1>
<b>
javascript can use standard http methods like <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html">GET, PUT, and DELETE</a> to create, modify, and manage files on a remote server. The only configuration needed on the server, is the allowance of public or user-based write permissions.
this can be done on window iis server by right-clicking a folder in the IIS web site folder-view.
chmod can be used on unix machines.
if you use apache, then you will need a bit of server-side code called a <a href="http://httpd.apache.org/docs/1.3/misc/FAQ.html#putsupport">put handler</a> to catch the PUT requests. (<a href="http://hpwww.ec-lyon.fr/~vincent/apache/mod_put.html">module here</a>)
</b>
<br />
<hr />
<br />
open <a href='newPage.htm' target="_blank">my new page</a> in a new tab/window.
<br />
<br />
<textarea rows='10' cols='80' id='userValue'>Hello World</textarea>
<br />
<br />
<input type='button' value='Save' onclick="doSave()" />
<input type='button' value='Load' onclick="doLoad()" />
<script type='text/javascript'>
function el(tid) {return document.getElementById(tid);}
function IO(U, V) {
//LA MOD String Version. A tiny ajax library. by, DanDavis
var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
X.open(V ? 'PUT' : 'GET', U, !1);
X.setRequestHeader('Content-Type', 'text/html')
X.send(V ? V : '');
return X.responseText;}
function doSave(){
IO("newPage.htm" , el("userValue").value );
}
function doLoad(){
el("userValue").value = IO("newPage.htm");
}
</script>
</body>
</html>[/HTML]