⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 afterpost.asp

📁 ASP+SQL Server动态网站开发从基础到实践教程
💻 ASP
字号:
<%@ Language=VBScript %>
<%
'这个asp文件的作用是将用户续写的新文章用文本文件的形式存起来
'新文章统一放在相对路径为new1/的文件夹之下,新文章名有一定的规则
'第一篇为newchapter1.html,第二篇为newchapter2.html按照文章发表的先后
'顺序,考虑到不能无限的让网上用户续写文章,最多能生成100篇
'新文章含有一些html标签,这样在制作连接时可以直接与该文件相连
'而不用使用程序读取文件再控制输出格式,制作连接是利用contentlink组件,
'这种组件的应用方法如后面所示,
'要利用到一个有一定格式描述连接的文本文件,这个文本文件名为new.txt
'也是存放在相对目录new1/下
if Request.ServerVariables("http_method")="POST" then
	set fsys=server.CreateObject("Scripting.filesystemobject")
	'取得文件夹的物理路径
	phypath=server.MapPath("../chap12")
	if not fsys.FolderExists(phypath & "/new1") then
		'如果存放新故事章节的文件夹不存在,则创建该文件夹
		fsys.CreateFolder(phypath & "/new1")
	end if 
	for i=1 to 100
		'每天接收的新的故事章节不大于100
		if not fsys.FileExists(phypath & "/new1/newchapter" & i &".html") then
			fsys.CreateTextFile(phypath & "/new1/newchapter" & i & ".html")
			set txtfile=fsys.OpenTextFile(phypath & "/new1/newchapter" & i & ".html",2,true)
			exit for
		end if
	next
	'向文件写提交的内容
	'将该文本文件写成html格式,浏览器能够直接读取该文件并按一定的格式显示
	title=Request.Form("title")
	author=Request.Form("author")
	content=Request.Form("content")
	txtfile.writeline "<html>"
	txtfile.writeline "<head>"
	txtfile.writeline "<title>" & title & "</title>"
	txtfile.writeline "</head>"
	txtfile.writeline "<body>"
	txtfile.writeline "<p align=center><font size=4 color=red>" & title & "</font>"
	txtfile.writeline "<font size=2 color=blue>作者:" & author & "</font></p>"
	txtfile.writeline "<pre>" & content & "</pre>"
	txtfile.writeline "</body>"
	txtfile.writeline "</html>"
	'关闭文件
	txtfile.close
	set txtfile=nothing
	'以下为添加新故事的目录到连接文件中
	set txtfile=fsys.OpenTextFile(phypath & "/new1/new.txt",8,true)
	txtfile.writeline  "new1/newchapter"  & i & ".html	"&"第" & i & "篇:" & Request.Form("title") & "(" & Request.Form("author") & ")"
	txtfile.close
	'打开刚写的文件
	set txtfile=fsys.OpenTextFile(phypath & "/new1/newchapter" & i & ".html",1)
	'读入文件的所有内容
	txtall=txtfile.readall
	'将文件的所有内容显示在浏览器
	Response.Write txtall
	txtfile.close
	set txtfile=nothing
end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<P>&nbsp;</P>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -