FSO使用问题:想给上传的文件加一个动态的路径该怎么做?例如:UP/动态目录/filename
<%filename=&request.form("title")&".html"'ifrequest("body")<>""thensetfso=Server.Crea...
<%
filename= &request.form("title") & ".html" '
if request("body")<>"" then
set fso = Server.CreateObject("Scripting.FileSystemObject")
set htmlwrite = fso.CreateTextFile(server.mappath("up/"&filename&"")) ' htmlwrite.write "<html><head><title>" & request.form("title") & "</title>" &request.form("css") &"</head>"
htmlwrite.write "<body>" & request.form("body")& "</body></html>"'输出标题与body内容
htmlwrite.close
set fout=nothing
set fso=nothing
end if
%>
答对了再加100分 展开
filename= &request.form("title") & ".html" '
if request("body")<>"" then
set fso = Server.CreateObject("Scripting.FileSystemObject")
set htmlwrite = fso.CreateTextFile(server.mappath("up/"&filename&"")) ' htmlwrite.write "<html><head><title>" & request.form("title") & "</title>" &request.form("css") &"</head>"
htmlwrite.write "<body>" & request.form("body")& "</body></html>"'输出标题与body内容
htmlwrite.close
set fout=nothing
set fso=nothing
end if
%>
答对了再加100分 展开
1个回答
展开全部
1.动态创建目录,要保证有写权限
2.然后,没有文件夹要建一个(Fso.CreateFolder)
还有什么问题hi我
<%
dim iFolderPath,FolderPath ,filename
filename= request.form("title") & ".html" '
iFolderPath = split (filename,"/")
select case iFolderPath(0)
case ""
response.write "没有写分类文件夹"
case "up"
response.write "文件写入了up根目录"
case else
FolderPath = "up/"&iFolderPath(0)
Set Fso=Server.CreateObject("Scri"&"pting.File"&"Sys"&"temObject")
If not Fso.FolderExists(Server.MapPath(FolderPath)) Then
Set F=Fso.CreateFolder(Server.MapPath(FolderPath))
CreateFolder=F.Path
End If
Set F=Nothing
Set Fso=Nothing
call writefiles(filename)
End Select
sub writefiles(filename)
if request("body")<>"" then
set fso = Server.CreateObject("Scripting.FileSystemObject")
set htmlwrite = fso.CreateTextFile(server.mappath("up/"&filename&"")) ' htmlwrite.write "<html><head><title>" & request.form("title") & "</title>" &request.form("css") &"</head>"
htmlwrite.write "<body>" & request.form("body")& "</body></html>"'输出标题与body内容
htmlwrite.close
set fout=nothing
set fso=nothing
end if
end sub
%>
2.然后,没有文件夹要建一个(Fso.CreateFolder)
还有什么问题hi我
<%
dim iFolderPath,FolderPath ,filename
filename= request.form("title") & ".html" '
iFolderPath = split (filename,"/")
select case iFolderPath(0)
case ""
response.write "没有写分类文件夹"
case "up"
response.write "文件写入了up根目录"
case else
FolderPath = "up/"&iFolderPath(0)
Set Fso=Server.CreateObject("Scri"&"pting.File"&"Sys"&"temObject")
If not Fso.FolderExists(Server.MapPath(FolderPath)) Then
Set F=Fso.CreateFolder(Server.MapPath(FolderPath))
CreateFolder=F.Path
End If
Set F=Nothing
Set Fso=Nothing
call writefiles(filename)
End Select
sub writefiles(filename)
if request("body")<>"" then
set fso = Server.CreateObject("Scripting.FileSystemObject")
set htmlwrite = fso.CreateTextFile(server.mappath("up/"&filename&"")) ' htmlwrite.write "<html><head><title>" & request.form("title") & "</title>" &request.form("css") &"</head>"
htmlwrite.write "<body>" & request.form("body")& "</body></html>"'输出标题与body内容
htmlwrite.close
set fout=nothing
set fso=nothing
end if
end sub
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询