ASP 窗体到文本文件



>我已经从在线资源中收集了一些代码,以将表单中的一些文本提交到文本文件中,现在我不知道我错过了什么,但没有任何内容通过文本文件,我猜这可能与文件夹路径有关,但我不确定, 只是在寻找这方面的一些方向。

我的 ASP 表单代码是:

<form method="get" action="simpleform.asp">
<br/>
<i>Please include your initials and date with the bug report</i> 
<br/>
<br/>
<b>Bug</b> <input type="text" name="bug">
<input type="submit" value="Submit Bug Report">
</form>
<br/>

ASP 将文本提交到文件的代码是这样的:

<html>
<body>
Thanks for the report! To report another bug <a href="BugReportPage.asp">click         here</a>.
<%
Dim idea
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile("G:GeneralEM_WikiWikiBugbugreport.txt",8,true)
idea= Request.QueryString("bug")

f.WriteLine(bug)
f.Close
set f=nothing
set fs=nothing
%>
</body>
</html>

希望这对某人有意义,并且您可以为我指出正确的方向,谢谢!

您没有将正确的变量写入文件。

f.WriteLine(bug)应该f.WriteLine(idea)

如果打开"选项显式",则更容易诊断此类问题。 以下是显示如何执行此操作的页面:http://msdn.microsoft.com/en-us/library/ms524870(v=vs.90).aspx

您的实际内容在变量idea中,而不是在bug中。 bug只是查询字符串的索引。此外,您可能需要flush您的流。

在关闭文件之前使用 flush 方法,e f.flush()

f.WriteLine(idea)
//your more writing
f.flush()
f.Close

这是 MSDN 链接

http://msdn.microsoft.com/en-us/library/system.io.streamwriter.flush.aspx

最新更新