<%
''文件删除函数
function deletefile(filename)
if filename<>"" then
set fso=server.CreateObject("scripting.filesystemobject")
if fso.FileExists(filename) then
fso.DeleteFile filename
else
Response.Write "<script>alert(''该文件不存在'');</script>"
end if
end if
end function
strfile=server.MapPath("fileName")
deletefile(strfile)
%>
'程序名:delfile.asp
'关键参数:struploadfiles 文件名称
例:<a href="/delfile.asp?action=test.rar">删除test.rar文件</a>
<%
struploadfiles=trim(request.querystring("struploadfiles"))
action=trim(request.querystring("action"))
response.write "成功删除<font color=red>"&struploadfiles&"</font>文件!"
call delfiles(struploadfiles & "")
sub delfiles(struploadfiles)
if struploadfiles="" then exit sub
dim fso,arruploadfiles,i
set fso = createobject("scripting.filesystemobject")
fso.deletefile(server.mappath("" & struploadfiles))
set fso = nothing
response.write"<script language=javascript>alert('成功删除文件,将返回上一页!');"
response.write"this.location.href='javascript:history.back();'</script>"
end sub
%>
<%
''文件删除函数
function deletefile(filename)
if filename<>"" then
set fso=server.CreateObject("scripting.filesystemobject")
if fso.FileExists(filename) then
fso.DeleteFile filename
else
Response.Write "<script>alert(''该文件不存在'');</script>"
end if
end if
end function
strfile=server.MapPath("fileName")
deletefile(strfile)
%>
Function DeleFile(FilePath)
On Error Resume Next
Set Del=Server.CreateObject("Scripting.FileSystemObject")
if Err <> 0 Then
DelFile="该空间不支持FSO组件,无法删除文件!"
else
if InStr(FilePath, ",") > 0 then
FilePath=Split(FilePath,",")
For i = 0 to ubound(FilePath)
If Del.FileExists(Server.MapPath(FilePath))=True Then Del.DeleteFile Server.MapPath(FilePath(i)),true
Next
Else
If Del.FileExists(Server.MapPath(FilePath))=True Then Del.DeleteFile Server.MapPath(FilePath),true
End if
End if
Set Del=Nothing
End Function
posted on 2006-06-15 14:10
blog搬家了--[www.ialway.com/blog] 阅读(1209)
评论(0) 编辑 收藏 所属分类:
PHP