日期:2014-05-17  浏览次数:21056 次

将页面内容写入文件的问题
filename= "menu.asp "
set   fout2   =   fso.CreateTextFile(server.mappath( "../ "&filename& " "))
fout2.write   Request.Form( "body ")
fout2.close

这样有错误:
无效的过程调用或参数

,但是

set   fout2   =   fso.CreateTextFile(server.mappath( "../ "&filename& " "))
response.write   Request.Form( "body ")
response.end()
fout2.write   Request.Form( "body ")
fout2.close
这样又能显示Request.Form( "body ")的内容,请问怎么解决这个写入文件的问题?  
这个menu.asp已经创建成功,就是在
fout2.write   Request.Form( "body ")
的时候,出现了 "无效的过程调用或参数 "这个错误

请问怎么解决?


------解决方案--------------------
CreateTextFile(filename, overwrite, unicode)
overwrite : true: 覆盖, false: no(默认)
unicode: true: 存为unicode格式, false(默认)

------解决方案--------------------
Request.Form( "body ")里是否有什么字符是参数产生歧义?
------解决方案--------------------
set fso = server.createobject( "scripting.filesystemobject ")
set fout2 = fso.CreateTextFile(server.mappath( "/app_data/test.asp "), true, false)
fout2.write ( "sdfsdf ")
fout2.close
set fso = nothing

并确保您的文件有写权限.
------解决方案--------------------
<%
if Request.Form( "btnsubmit ") <> " " then
set fso = server.createobject( "scripting.filesystemobject ")
set fout2 = fso.CreateTextFile(server.mappath( "/app_data/test.asp "), true, false)
fout2.write (Request.Form( "test "))
fout2.close
set fso = nothing
end if
%>
<form method= "post ">
<input type= "text " name= "test " /> <input type= "submit " name= "btnsubmit " value= "保存 " />
</form>

测试通过