读去用户的原来文件内容
<%
Dim write
Dim fileSysObj, tf, read
' 读取文本read.txt
'获得文件名字
read = "read.txt"
'读取文件的完整路径
read = LEFT(Server.Mappath(Request.ServerVariables("PATH_INFO")), InStrRev(Server.Mappath
(Request.ServerVariables("PATH_INFO")), "\")) & read
'新建一个fileSysObj对象
Set fileSysObj = createObject("Scripting.FileSystemObject")
'读取整个文本文件
IF (fileSysObj.FileExists(read)) Then
'如果文件存在,则打来并读取文件
Set tf = filesysobj.OpenTextFile(read, 1)
read = tf.ReadLine
tf.Close
ELSE
'如果找不到read.txt文件,则显示下面的信息!
read = "没有相应的文件"
END IF
%>
'在下面表格中显示read.txt
<div align="center">
<form method="POST" action="write_txt.asp">
<table border="0" width="40%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" ><textarea name="S1" rows="1" cols="20" ><%=read%></textarea></td>
</tr>
<tr>
<td>
<input type="submit" value="提交" name="B1">
</tr>
</table>
</form>
用户编辑完了以后 点击 提交
write_txt.asp 代码
<%
Sub Write2File(strFile , strContent, blnAppend)
' 写入文件
' strFile 文件名(路径) , strContent 写入的内容, blnAppend 是否追加
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If blnAppend Then
Set objWriteText = objFSO.OpenTextFile(strFile,8,True)
Else
Set objWriteText = objFSO.OpenTextFile(strFile,2,True)
End If
objWriteText.WriteLine (strContent)
Set objWriteText = Nothing
Set objFSO = Nothing
' 容错处理
Select Case Err
Case 424 Response.Write "路径未找到或者该目录没有写入权限."
Case Else Response.Write Err.Description
End Select
End Sub
user_txt=request.form("s1")
Call Write2File ("read.txt", user_txt, True)
%>
read.txt 可以有系统命名,或随即生成,那就看你了
偶不会操作word文档,就给你一个txt的吧,希望对你有帮助