Display JPEG using Response.BinaryWrite

前端 未结 3 372
无人共我
无人共我 2021-01-15 02:41

I\'m displaying an image like this:


counter.asp is doing a hit-counter do determine how often the

3条回答
  •  醉话见心
    2021-01-15 03:23

    To read and output binary you can simply use the ADODB.Stream object.

    See the ADODB.Stream MSDN Library:
    http://msdn.microsoft.com/en-us/library/ms675032(VS.85).aspx

    Here's an example I found from Experts Exchange as well:

    Function ReadBinaryFile(strFileName) 
            on error resume next 
            Set oStream = Server.CreateObject("ADODB.Stream") 
            if Err.Number <> 0 then 
                    ReadBinaryFile=Err.Description 
                    Err.Clear 
                    exit function 
            end if 
            oStream.Type = 1  
            oStream.Open 
    
            oStream.LoadFromFile strFileName 
            if Err.Number<>0 then 
                    ReadBinaryFile=Err.Description 
                    Err.Clear 
                    exit function 
            end if 
            ReadBinaryFile=oStream.Read 
            oStream.Close 
            set oStream = nothing 
            if Err.Number<>0 then ReadBinaryFile=Err.Description 
    End Function  
    

提交回复
热议问题