Click to See Complete Forum and Search --> : Create new htm file from asp file, can I do that ?


cat
06-17-2003, 10:22 PM
from asp file, can I create new htm file and save it to server ?

In my asp file, I have the form with input textbox. When

user types something in it and click submit, how can I

create new htm file, which store the text had typed by

the user in <body> tag ?

Example, the user typed : This is my opinion

And new htm file,which I want to create and save on my

server will be as follows :

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>

This is my opinion

</BODY>
</HTML>

Can I do that by write code in asp file ? Thank you.

Bullschmidt
06-18-2003, 03:27 AM
Or perhaps (if it's OK if the page that receives a post is an .asp page instead of .htm), then you could have it be like this:

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<%= Request.Form("MyTextBox") %>
</BODY>
</HTML>

cat
06-18-2003, 04:16 AM
Thank you very much

Dave Clark's code works perfectly. I apply it in my asp file :

<%
....
txt = objOpenFile.ReadAll ' read the entire file at once
.....

txt2=Request.Form("mytextbox").value

txt=replace(txt,"insert_new_text_here",txt2)

set fso=Server.CreateObject("Scripting.FileSystemObject")
set myfile=fso.CreateTextFile("c:\myfolder\des.htm",true)
myfile.write(txt)
myfile.close
set fso=nothing
set myfile=nothing
set objFSO=nothing
%>
Dave Clark, I think you are an intelligent teacher. Your code is a clear answer.