Click to See Complete Forum and Search --> : Write .txt from html page


Tea.Cup
04-13-2003, 09:48 AM
I need to store information from user to a file on the harddrive.

I don't have CGI or database rights.

Any ideas'

I am quite 'dof' and need a working example.

Nevermore
04-13-2003, 10:51 AM
Do you have PHP or ASP? Without any type of server side script, it can't be done.

devinabox
04-13-2003, 12:00 PM
You could create a form, and get the user's info in that form, then use the mailto action, which would send you the form info...

Here is a pretty good tutorial on this subject : http://www.wdvl.com/Authoring/HTML/Forms/mailto.html

Nevermore
04-13-2003, 12:02 PM
That would work, but would be more work than if the server supports PHP.

devinabox
04-13-2003, 02:31 PM
that's very true...if the server supports some server-side scriptiing, that would be the very best way to go...the email form has serious compatibility issues, and really only serves as a 'last resort'...

viravan
04-13-2003, 06:17 PM
I wrote this for IE a few years back....give it a try and see if it works without signing the script:


function aok_IE_WriteLocal(file,wFlag,buffer) {
var fso=new ActiveXObject('Scripting.FileSystemObject');
var bfw=fso.OpenTextFile(file,wFlag,true);
bfw.WriteLine(buffer);
bfw.close();
}


wFlag is 2 for a new file, 8 for append to an existing file.

:)

V.V.

Nevermore
04-14-2003, 05:12 AM
No client-side JavaScript can save files to the server, signed or not.

viravan
04-14-2003, 09:00 AM
Originally posted by cijori
No client-side JavaScript can save files to the server, signed or not.

Hmmm....... sorry, I was under the impression from reading the discussions that the idea is to store the HTML in the user's hard drive.

In any event, if the server supports ASP, perhaps the following from my archive (tested on Windows 98SE/PWS) will work:


<html>
<head>
<%
Dim myMessage
if request.querystring("lName") <> "" then
Dim FSO, TxtFile,firstName,lastName,ID,record
DBFile = "c:/Inetpub/IISSamples/default/NameList.txt"
firstName = request.querystring("fName")
lastName = request.querystring("lName")
ID = request.querystring("ID")
Set FSO = CreateObject("Scripting.FileSystemObject")
record = firstName & "," & lastName & "," & ID
IF Not (FSO.FileExists(DBFile)) Then
set TxtFile = FSO.CreateTextFile(DBFile)
Else
set TxtFile = FSO.OpenTextFile(DBFile,8)
End If
TxtFile.WriteLine record
TxtFile.close
myMessage = "The record has been added ok"
Set TxtFile = nothing
Set FSo = nothing
else
myMessage = "Please enter your First Name, Last Name and the ID you want to use"
end if
%>
</head>
<body>
<h2><%=myMessage%></h2>
<table>
<form name="form1">
<tr>
<td>First Name</td>
<td><input type="text" name="fName"></td>
</tr>
<tr>
<td>Last Name</td>
<td><input type="text" name="lName"></td>
</tr>
<tr>
<td>ID</td>
<td><input type="text" name="ID"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="update" value="Update Values"></td>
</tr>
</form>
</table>
</body>
</html>



:)

V.V.

Nevermore
04-14-2003, 11:35 AM
Originally posted by viravan
Hmmm....... sorry, I was under the impression from reading the discussions that the idea is to store the HTML in the user's hard drive.

You're no worse of than me - I'm not sure where the file is being stored, but from the mention of CGI and database rights, I'm guessing that it's on the server.

David Harrison
04-14-2003, 01:17 PM
Just out of interest how would you create/save/modify a txt document on your own PC (to an address that can be specified). Because at school we've got a right ******* for a systen administrator and he's disabled all of the programs like notepad, wordpad and stuff like that.
Would it be possible to open text files (maybe html files) with it as well?