Fux*_*uxi 2 vbscript asp-classic binarywriter
我正在显示这样的图像:
<img src='counter.asp'>
Run Code Online (Sandbox Code Playgroud)
counter.asp正在做一个点击计数器确定图像显示的频率(我将用modrewriteURL 替换它).
问题:在counter.asp脚本中我需要将实际.jpg图像发送到浏览器.怎么可以这样做?我想我需要通过FSO加载图像,然后使用Response.BinaryWrite- 任何想法发送它?
Mic*_*cah 10
要读取和输出二进制文件,只需使用ADODB.Stream对象即可.
请参阅ADODB.Stream MSDN Library:http://msdn.microsoft.com/en-us/library/ms675032( VS.85)
.aspx
这是我从Experts Exchange发现的一个例子:
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
Run Code Online (Sandbox Code Playgroud)