網路城邦
上一篇 回創作列表 下一篇   字體:
asp下載檔案
2013/10/09 09:26:27瀏覽148|回應0|推薦1

<% br="">sn = cint(Now_GET("sn"))
name_file = session("doc_dl_file")

if sn=0 or name_file="" then
    CALL Tjs_Alert("表單接收錯誤...","history.go(-1);")
  response.end()
end if

pos=InstrRev(name_file,".")
SubName=mid(name_file,pos)

Select Case LCase(SubName)
        Case ".pdf"
            Response.ContentType = "application/pdf"
        Case ".asf"
            Response.ContentType = "video/x-ms-asf"
        Case ".avi"
            Response.ContentType = "video/avi"
        Case ".doc"
            Response.ContentType = "application/msword"
        Case ".zip"
            Response.ContentType = "application/zip"
        Case ".xls"
            Response.ContentType = "application/vnd.ms-excel"
        Case ".gif"
            Response.ContentType = "image/gif"
        Case ".jpg", "jpeg"
            Response.ContentType = "image/jpeg"
        Case ".wav"
            Response.ContentType = "audio/wav"
        Case ".mp3"
            Response.ContentType = "audio/mpeg3"
        Case ".mpg", "mpeg"
            Response.ContentType = "video/mpeg"
        Case ".rtf"
            Response.ContentType = "application/rtf"
        Case ".htm", "html"
            Response.ContentType = "text/html"
        Case Else
            Response.ContentType = "application/octet-stream"
    End Select
    

response.addheader "Content-Disposition","attachment; filename=" & chr(34) & name_file & chr(34)
response.binarywrite getBinaryFile(server.mappath(getpic_ph&name_file))
   
function getBinaryFile(fileSpec)
    Dim adTypeBinary
    adTypeBinary = 1
    Dim oStream
     set oStream = server.createobject("ADODB.Stream")
     oStream.Open
     oStream.Type = adTypeBinary
     oStream.LoadFromFile fileSpec
     getBinaryFile= oStream.read
     set oStream=nothing
end function
%>
( 興趣嗜好電腦3C )
列印 加入我的文摘
上一篇 回創作列表 下一篇

引用
引用網址:https://classic-blog.udn.com/article/trackback.jsp?uid=takaprog&aid=8943463