主頁 > 知識庫 > ASP實現(xiàn)文件直接下載的代碼

ASP實現(xiàn)文件直接下載的代碼

熱門標簽:地圖標注服務(wù)哪家好 西寧公司外呼系統(tǒng)平臺 智能電銷機器人適用于哪些行業(yè) 騰訊地圖標注商戶關(guān)閉 武漢營銷電話機器人軟件 地圖標注宅基地 外呼系統(tǒng)還用卡么 長沙防封電銷卡品牌 徐州人工智能電銷機器人好用嗎
%@ language=vbscript codepage=65001%>
%
'Filename must be input
if Request("Filename")="" then
response.write "h1>Error:/h1>Filename is empty!p>"
else
call downloadFile(replace(replace(Request("Filename"),"\",""),"/",""))

Function downloadFile(strFile)
' make sure you are on the latest MDAC version for this to work
' get full path of specified file
strFilename = server.MapPath(strFile)

' clear the buffer
Response.Buffer = True
Response.Clear

' create stream
Set s = Server.CreateObject("ADODB.Stream")
s.Open

' Set as binary
s.Type = 1

' load in the file
on error resume next

' check the file exists
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("h1>Error:/h1>"strFilename" does not exists!p>")
Response.End
end if

' get length of file
Set f = fso.GetFile(strFilename)
intFilelength = f.size

s.LoadFromFile(strFilename)
if err then
Response.Write("h1>Error: /h1>Unknown Error!p>")
Response.End
end if
' send the headers to the users Browse
Response.AddHeader "Content-Disposition","attachment; filename="f.name
Response.AddHeader "Content-Length",intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
' output the file to the browser
Response.BinaryWrite s.Read
Response.Flush
' tidy up
s.Close
Set s = Nothing
End Function
end if
%>

標簽:運城 雅安 普洱 巴彥淖爾 荊門 鷹潭 通遼 通化

巨人網(wǎng)絡(luò)通訊聲明:本文標題《ASP實現(xiàn)文件直接下載的代碼》,本文關(guān)鍵詞  ASP,實現(xiàn),文件,直接,下載,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP實現(xiàn)文件直接下載的代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于ASP實現(xiàn)文件直接下載的代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章