导航: 好喜爱学习网 >> 网站制作 >> asp教程 >> 如何用ASP直接将服务器端的某个文件夹下的所有文件下载到客户端指定的文件夹中
相关文章
最新文章
文章内容
如何用ASP直接将服务器端的某个文件夹下的所有文件下载到客户端指定的文件夹中
作者:未知 来源:网络收集 录入:管理员
    除过黑客代码,正常情况下,是不好实现的,特别是,还不给客户端任何提示。
 
---------------------------  
远程获取内容,并将内容存在本地电脑上,包括任何文件  
 
〈%  
’---------------利用xmlhttp和adodb.stream-----------------  
’On  Error  Resume  Next  
’Set  the  content  type  to  the  specific  type  that  you  are  sending.  
’Response.ContentType  =  “IMAGE/JPEG“  
’-------------------------------定义输出格式-----------------------------  
 
Path=request.querystring(“p“)  
sPath  =  Path  
if  left(lcase(path),7)  〈〉  “替换“  then  
’-------------如果前面没有http就是本地文件,交给LocalFile处理------------  
LocalFile(path)  
else  
’--------------------否则为远程文件,交给RemoteFile处理------------------  
RemoteFile(Path)  
end  if  
’Response.Write  err.Description  
 
sub  LocalFile(Path)  
’-------------------如果为本地文件则简单的跳转到该页面-------------------  
Response.Redirect  Path  
End  Sub  
 
Sub  RemoteFile(sPath)  
’-------------------------处理远程文件函数------------------------------  
FileName  =  GetFileName(sPath)  
’-------------GetFileName为把地址转换为合格的文件名过程-------------  
FileName  =  Server.MapPath(“/UploadFile/Cache/“  &  FileName)  
Set  objFso  =  Server.CreateObject(“Scripting.FileSystemObject“)  
’Response.Write  fileName  
if  objFso.FileExists(FileName)  Then  
’--------------检查文件是否是已经访问过,如是,则简单跳转------------  
Response.Redirect  “/uploadfile/cache/“  &  GetFileName(path)  
Else  
’----------------否则的话就先用GetBody函数读取----------------------  
’Response.Write  Path  
t  =  GetBody(Path)  
’-----------------用二进制方法写到浏览器上--------------------------  
Response.BinaryWrite  t  
Response.Flush  
’-----------------输出缓冲------------------------------------------  
SaveFile  t,GetFileName(path)  
’------------------将文件内容缓存到本地路径,以待下次访问-----------  
End  if  
Set  objFso  =  Nothing  
End  Sub  
 
Function  GetBody(url)  
’-----------------------本函数为远程获取内容的函数---------------------  
’on  error  resume  next  
’Response.Write  url  
Set  Retrieval  =  CreateObject(“Microsoft.XMLHTTP“)  
’----------------------建立XMLHTTP对象-----------------------------  
With  Retrieval  
.Open  “Get“,  url,  False,  ““,  ““  
’------------------用Get,异步的方法发送-----------------------  
.Send  
’GetBody  =  .ResponseText  
GetBody  =  .ResponseBody  
’------------------函数返回获取的内容--------------------------  
End  With  
Set  Retrieval  =  Nothing  
’response.Write  err.Description  
End  Function

E-MAIL:309076721@163.com
本站为非营利性质个人网站,建站只为个人爱好与学习,内容大多为电脑技术教程;
网站内容来源于互联网收集整理,禁止用于非法途径,如发现本网站上有侵权的文章请联系我们,我们会尽快删除;
本站不对站点内容准确性、完整性和真实性作任何承诺,由此产生的后果本站不承担任何责任,对以上引起的一切法律纠纷本站无权利承担。