转------------
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
Function GetFileName(str)
''-------------------------本函数为合格化的文件名函数-------------------
str = Replace(lcase(str),"http://";,"")
str = Replace(lcase(str),"//","/")
str = Replace(str,"/","")
str = replace(str,
vbcrlf,"")
GetFileName = str
End Function
sub SaveFile(str,fName)
''-------------------------本函数为将流内容存盘的函数-------------------
''on error resume next
Set objStream = Server.CreateObject("ADODB.Stream")
''--------------建立ADODB.Stream对象,必须要ADO 2.5以上版本---------
objStream.Type = adTypeBinary
''-------------以二进制模式打开-------------------------------------
objStream.Open
objstream.write str
''--------------------将字符串内容写入缓冲--------------------------
''response.Write fname
objstream.SaveToFile "c:\inetpub\myweb\uploadfile\cache\" & fName,adSaveCreateOverWrite
''--------------------将缓冲的内容写入文件--------------------------
''response.BinaryWrite objstream.Read
objstream.Close()
set objstream = nothing
''-----------------------关闭对象,释放资源-------------------------
''response.Write err.Description
End sub
%>