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分
展开
 我来答
zwb12340
2010-10-26 · TA获得超过257个赞
知道小有建树答主
回答量:251
采纳率:0%
帮助的人:280万
展开全部
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
%>
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式