時(shí)間:2015-06-28 00:00:00 來(lái)源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評(píng)論(0)
以下為引用的內(nèi)容: <% FunctIon DownloadFIle(StrFIle) StrFIlename=StrFIle Response.Buffer=True Response.Clear Set S=Server.CreateObJect("ADODB.Stream") S.Open S.Type=1 on Error Resume Next Set Fso=Server.CreateObJect("ScrIptIng.FIleSystemObJect") If Not Fso.FIleExists(StrFIleName) Then From_Url=Cstr(Request.ServerVarIables("HTTP_REFERER")) Serv_Url=Cstr(Request.ServerVarIables("SERVER_NAME")) If MId(From_Url,8,len(Serv_Url)) <> Serv_Url Then Response.WrIte "該文件不存在或者已經(jīng)刪除." Response.End End If Response.RedIrect Request.ServerVarIables("HTTP_REFERER") Response.End End If FileExt=MId(StrFIlename,InStrRev(StrFIleName, ".")+1) Select Case UCase(FIleExt) Case "ASP", "ASA", "ASPX", "ASAX", "MDB", "PHP", "JSP", "SHTML", "HTML", "HTM", "TV", "DATA" From_Url=Cstr(Request.ServerVarIables("HTTP_REFERER")) Serv_Url=Cstr(Request.ServerVarIables("SERVER_NAME")) If MId(From_Url,8,len(Serv_Url)) <> Serv_Url Then Response.WrIte "該文件不存在或者已經(jīng)刪除." Response.End End If Response.RedIrect Request.ServerVarIables("HTTP_REFERER") Response.End End Select Set F=Fso.GetFIle(StrFIlename) IntFIlelength=F.SIze s.LoadFromFIle(StrFIlename) If Err Then From_Url=Cstr(Request.ServerVarIables("HTTP_REFERER")) Serv_Url=Cstr(Request.ServerVarIables("SERVER_NAME")) If MId(From_Url,8,len(Serv_Url)) <> Serv_Url Then Response.WrIte "該文件數(shù)據(jù)不完整或許已損壞." Response.End End If Response.RedIrect Request.ServerVarIables("HTTP_REFERER") Response.End End If Set Upload=Server.CreateObJect("PersIts.Upload") If Upload Is Nothing Then Response.AddHeader "Content-DIsposItIon","attachment; FIlename="&F.Name Response.AddHeader "Content-Length",IntFilelength Response.CharSet="UTF-8" Response.ContentType="application/x-download" Response.BinaryWrite S.Read Response.Flush S.Close Set s=NothIng Else Upload.SendBinary StrFIlename,True,"application/x-download",False End If End FunctIon %> |
調(diào)用
<%Call DownloadFIle("下載地址")%>
關(guān)鍵詞標(biāo)簽:ASP
相關(guān)閱讀
熱門文章 ASP編程代碼:隱藏圖片的真實(shí)地址 ASP教程:0177:800401f3錯(cuò)誤解決 ASP代碼中如何屏蔽ip地址 禁止某IP段訪問(wèn)網(wǎng)站 錯(cuò)誤80004005信息處理方法
人氣排行 ASP下標(biāo)越界的解決方法 ASP代碼中如何屏蔽ip地址 禁止某IP段訪問(wèn)網(wǎng)站 “文件共享鎖定數(shù)溢出” 原因及解決方法 無(wú)法寫入數(shù)據(jù)庫(kù)的解決方法 ASP教程:0177:800401f3錯(cuò)誤解決 ASP常用函數(shù)列表 如何用ASP來(lái)獲取客戶端真實(shí)IP的地址 ASP用FSO生成HTML簡(jiǎn)單實(shí)例+詳解[原創(chuàng)]