Asp生成HTML方法大全(2)


Astream.type=2'文件类型文本
Astream.Mode = 3'读写
Astream.open
Astream.CharSet = "GB2312"'字符集
Astream.LoadFromFile(tempelatefile)'从文件装载
Assp=Astream.size
if err.number<>0 then
xz=-18
response.Write tempelatefile&"<br>"
err.clear
tmpdata=""
else
tmpdata=Astream.ReadText(Assp)
end if

end sub

sub save_file()
ofile()
recfilen=server.MapPath(dts)
Astream.Flush
Astream.close
Astream.type=2
Astream.Mode = 3
Astream.open
Astream.CharSet = "GB2312"
Astream.position=0
Astream.Writetext tmpdata,1'写入数据到stream
Astream.SaveToFile recfilen,2'保存到文件
end sub

function dts()'产生随机文件名
if len(month(now()))>1 then
mm=month(now())
else
mm="0"&month(now())
end if
if len(day(now()))>1 then
d=day(now())
else
d="0"&day(now())
end if
if len(hour(now()))>1 then
h=hour(now())
else
h="0"&hour(now())
end if
if len(minute(now()))>1 then
m=minute(now())
else
m="0"&minute(now())
end if
if len(second(now()))>1 then
s=second(now())
else
s="0"&second(now())
end if
Randomize
upperbound=9999
lowerbound=1000
rds=Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
dts="htm/"&year(now())&mm&d&h&m&s&rds&".htm"
end function
title=request.Form("title")
content=request.Form("content")
tmpdata=replace(tmpdata,"<title></title>",title)'以拥护提交内容替换
tmpdata=replace(tmpdata,"<content></content>",content)
tempelatefile=server.MapPath("tempelate/1.htm")'模版文件
save_file()
%>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3689.html