Asp编程

ASP用FSO生成HTML简单实例+详解[原创]

日期:2015-06-28 00:00:00 来源: IT猫扑网

以下为引用的内容:
<%
Dim post,filename,path,path1,yes,content
post=request("post")
filename=request("filename")
path=request("path")
path1=replace(path,"/","")
yes=request("yes")
content=request("content")

If post=1 Then
        If filename="" Or path="" Or yes="" Or content="" Then
                response.write "对不起你有某项内容没有填写无法生成!" '如果用户信息填写不完全就返回错误信息
                response.End
        else
                set fso = Server.CreateObject("Scripting.FileSystemObject") '设置FSO对象

                If yes=1 Then '如果用户选择了"如果路径不存在就创建新文件夹",
                        If Not fso.FolderExists(server.mappath(""&path&"")) Then  '则检查用户输入的文件夹是否存在
                                fso.CreateFolder (server.mappath(""&path1&"")) '不存在就自动创建
                        End If
                        Else  '如果用户选择了"如果路径不存在不自动创建新文件夹",
                        If not fso.FolderExists(server.mappath(""&path&"")) Then '则检查用户输入的文件夹是否存在
                                response.write "路径不存在,请后退重新输入!"  '如果路径不存在就提示用户返回重写
                                response.End
                        End If
                End If
        End If
        set fout = fso.CreateTextFile(server.mappath(""&path&"/"&filename&""))  '设置一个对象fout创建文件

        fout.write content '把文件内容写入文件
        response.write "生成成功!" '给用户返回生成成功的信息
        response.end
        fout.close '关闭fout对象
        set fout=Nothing '清空fout对象
        set fso=Nothing '清空FSO对象
End If
%>


要生成的文件内容:


   


  如果路径不存在就创建新文件夹:是 
  


  路 径:

  


  文件名:
  


  
  
  

  

相关文章

相关下载

网友评论

我要评论...
    没有更早的评论了
    取消