注册 登录
编程论坛 ASP技术论坛

关于下载的问题,急!!!

wanghua09 发布于 2009-11-04 19:31, 433 次点击
再下載文件時,在若網路設有防火牆,則網頁會顯示【無法顯示此頁】,怎麼辦?請路過大俠指引.
急!急!急!!

下載文件:
<%
strFile="c_comp.exe"

call downloadFile(strFile)

function downloadFile(strFile)
    strFilename = server.MapPath(strFile)
   
    Response.Buffer = True
    Response.Clear
   
    Set fso=Server.CreateObject("Scripting.FileSystemObject")
        if not fso.FileExists(strFilename) then
        Response.Write("沒找到文件")
        Response.End
        end if
    Set fl=fso.getfile(strFilename)  
    flsize=fl.size  
    flName=fl.name
    Set fl=Nothing  
    Set fso=Nothing  
    Set objStream  =  Server.CreateObject("ADODB.Stream")  
    objStream.Open  
    objStream.Type  =  1  
    objStream.LoadFromFile  strFilename  
   
    Response.AddHeader  "Content-Disposition",  "attachment;  filename="  &  flName  
    Response.AddHeader  "Content-Length",  flsize  
    Response.Charset  =  "big5"  
    Response.ContentType  =  "application/unknow"  
    Response.BinaryWrite  objStream.Read  
    Response.Flush  
    response.Clear()  
    objStream.Close  
    Set  objStream  =  Nothing                        
End Function

%>

[ 本帖最后由 wanghua09 于 2009-11-4 19:36 编辑 ]
1 回复
#2
wanghua092009-11-05 09:33
回复 楼主 wanghua09
問題補充:也可以判斷如果頁不能下載,顯示提示也可以
1