I have only the most basic knowledge of web scripting, but i’m trying to learn something.
Here what I want to do:
I have a place in a server of my university and have a page there, id like to have some output of what happened in there. So i want to write into a file on click, which places in the same folder as html, also I would like to know how to open file at the end of it (like fstream::app in c++) and get system time.
Here’s what I wrote:
<HTML>
<SCRIPT language="JavaScript">
function WriteFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("/net/my path/2011/rija9995/www/Test.txt", true);
fh.WriteLine("Some text goes here...");
fh.Close();
}
</SCRIPT>
<HEAD>
<TITLE>title</TITLE>
</HEAD>
<BODY VLINK=#FF0000 link=#FF0000 alink=#FF0000 bgcolor=#aaaa88 text=#FFFFFF>
<H6>
<TT><CENTER><h2>
<br><br><br><br><br><br><br><br><br><br><br><br><br>
blah blah blah
<button id="button" type="text" onClick="javascript: WriteFile();" />x</button>
</BODY>
</HTML>
Java script cannot have control on server side file system. You need to use a server side language instead i.e cgi-scripts/PHP/Java servlets etc. See this for more details.