View Full Version : write to page permantately
scroots
06-27-2002, 08:47 PM
how would one using a simple form write text to a page forever,until the page with the text in is deleted.
thanks in advance.
scroots
QuackHead
06-27-2002, 10:16 PM
you'd have to use the file system object.
Are you writing to a text file, html file, etc.?
Let me know, in the mean time I'll write you a good example of writing stuff to a text file.
~Quack
whammy
06-28-2002, 01:05 AM
Or, you can check out the examples at:
http://www.w3schools.com
They should get you started !
oracleguy
06-28-2002, 05:41 AM
But....
Make sure that the web server has write permissions enabled on the folder containing the file. Or less you'll be plegued with access denied errors.
scroots
06-29-2002, 09:16 AM
it would be written to a html file .
thanks everyone.
scroots
QuackHead
07-03-2002, 03:57 PM
Sorry scroots, completely forgot about my promise....
as promised, here's a simple example of how to write to an html file... (actually - this creates the file...)
<%@Language=VBScript%>
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set fs = fso.CreateTextFile("FULL_PATH_TO_YOUR_FILE", true)
fs.writeline("<html>")
fs.writeline("</html>")
fs.Close
set fs = nothing
set fso = nothing
%>
Hope this gives you some insight ... althought I'm sure you may have figured all this out already.
~Quack
QuackHead
07-03-2002, 04:02 PM
Hey, if you want to add text to an exisiting file, change:
CreateTextFile("FULL_PATH_TO_YOUR_FILE", True)
to
OpenTextFile("FULL_PATH_TO_YOUR_FILE")
If you have more questions, post and we'll help :D
~Quack
scroots
07-08-2002, 08:09 PM
thanks guys i`m a liitle busy at the moment thanks for your replies its for a litle project i`m making.
scroots
scroots
07-08-2002, 08:11 PM
got the idea but i need it from a simple form (text area) with a send button.
it will help me learn ASP.
please;) ;)
scroots
QuackHead
07-08-2002, 09:50 PM
Easiest way to do this is just read from the textarea and write it to the file.... it may not be formatted in the nicest looking way, but the output will stay the same...
Html page
<form action="YOUR_ASP_PAGE.ASP" method="post">
<textarea rows="10" cols="30" name="theText"></textarea>
<br>
<input type="submit">
</form>
in the ASP page that you submit your form to, have the line
fs.write(Request.Form("theText")) instead of the fs.writeline statements.
ASP Page
<%@Language=VBScript%>
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set fs = fso.CreateTextFile("FULL_PATH_TO_YOUR_FILE", true)
fs.write(Request.Form("theText"))
fs.Close
set fs = nothing
set fso = nothing
%>
That should do the trick,
let me know if you need any clarification.
~Quack
scroots
07-09-2002, 04:48 PM
thank you, i understand now.
thanks
scroots
QuackHead
07-09-2002, 06:31 PM
No problem.
:thumbsup:
~Quack
scroots
07-14-2002, 05:30 PM
quack my code i have done doesn`t write to a file or even make a file. could you please help me, my code:
the form page:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<form action="myasp.asp" method="post">
<textarea rows="10" cols="30" name="theText"></textarea>
<br>
<input type="submit">
</form>
</body>
</html>
the other page (myasp.asp):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<%@Language=VBScript%>
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set fs = fso.CreateTextFile("my.txt", true)
fs.write(Request.Form("theText"))
fs.Close
set fs = nothing
set fso = nothing
%>
</body>
</html>
the first page does the form action (sends to myasp.asp) but myasp.asp does not write to a file.
can anyone help?
scroots
whammy
07-14-2002, 06:18 PM
That worked fine for me - however I had to map the path to the directory on my server (database) that has write permissions.:
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<%@Language=VBScript%>
<%
sMapPath = Server.MapPath("\")
sMapPath = Mid(sMapPath, 1, InStrRev(sMapPath,"\")-1) & "\database\my.txt"
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set fs = fso.CreateTextFile(sMapPath, true)
fs.write(Request.Form("theText"))
fs.Close
set fs = nothing
set fso = nothing
%>
</body>
</html>
Are you getting an error, or what?
scroots
07-14-2002, 06:28 PM
it doesn`t create or write to the file.
scroots
scroots
07-14-2002, 06:30 PM
i`m testing it on my PC using PWS, my other ASP (counter) script works, so i doubt it is PWS.
scroots
whammy
07-16-2002, 01:26 AM
If it's not doing either one (or either), you should *definitely* be getting an error. Are you sure you're looking in the right place?!?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.