欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp在IE瀏覽器中下載服務(wù)端上的各類文件的實現(xiàn)方法

 更新時間:2007年11月11日 21:51:53   作者:  
即直接提示用戶下載而不是由瀏覽器打開某些文件。注意,下面的代碼拷貝到ASP文件中后,不要再添加一些非ASP代碼在頁面中:如HTML和javascript客戶端的代碼。 
復(fù)制代碼 代碼如下:

<%
'--------------------------------------------
Response.Buffer = True
Dim strFilePath, strFileSize, strFileName
Const adTypeBinary = 1
strFilePath = "文件路徑 "
strFileSize = ... 文件大小,可選
strFileName = "文件名"
Response.Clear
'8*******************************************8
' 需要在你的服務(wù)器上安裝 MDAC 2.6 或MDAC2.7
'8*******************************************8
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
strFileType = lcase(Right(strFileName, 4)) '文件擴(kuò)展名 站.長.站 
' 通過文件擴(kuò)展名判斷 Content-Types
Select Case strFileType
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".asp"
ContentType = "text/asp" 
Case Else
'Handle All Other Files
ContentType = "application/octet-stream"
End Select
Response.AddHeader "Content-Disposition", "attachment; filename= strFileName
Response.AddHeader "Content-Length", strFileSize
Response.Charset = "UTF-8" ' 客戶端瀏覽器的字符集UTF-8
Response.ContentType = ContentType
Response.BinaryWrite objStream.Read
Response.Flush
objStream.Close
Set objStream = Nothing
%> 

相關(guān)文章

最新評論