View Full Version : Form Textfield to modify a file?

12-18-2003, 02:00 AM

I'm trying to find a way that a User can go to a specific website that would allow them to enter some text that would then be shown on the primary website.

I thought I could have a form with just a textarea box. Then whatever they entered could be sent to a TXT or HTML file which could be Included onto the primary page.

How wouls I go about doing this so that any time the form is used, it would overwrite anything that was in the file before. Or ever better, when they go to the form it would read whatever was in the file into the box, and then let them edit it or change it all, and then re-write it back to the file.

Is this doable in ASP or is there a better way to do this?

Any input is much appreciated.


12-18-2003, 08:49 AM
Well, here some useful links you might want to read.

Opening text files:

Creating text files:

Other methods and properties of the FileSystemObject:

12-18-2003, 02:18 PM
This is the text from the first link you posted:

dim filesys, filetxt
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile("c:\somefile.txt", ForAppending, True)
filetxt.WriteLine("Your text goes here.")

Which part of that does the actual writing to the file? And, how can I edit it to make it pull the text to write from a form field?

I'm assuming I do it like this...

1) Use the script above (or part of it) to open the file and read in the current file's contents into a TextArea into a form.
2) Allow user to modify what's in the TextArea window
3) Set up a button so when they click it, it would write the new contents of the TextArea window to the file and OverWrite whatever might have been in there before.

But, I know next to nothing about ASP so if someone could explain it in a bit more detail for me, that'd be great!

12-19-2003, 03:09 AM
But, I know next to nothing about ASP so if someone could explain it in a bit more detail for me, that'd be great!

I think you should learn about ASP and VBScript first.

12-19-2003, 02:04 PM
Learn the whole language just to do this one tiny script? I'd love to but I'd rather have this working ASAP and then learn how and why it works and go from there.