Image type and size

T

Tumurbaatar S.

My ASP app dynamically retrieves from db and sends JPG images
using Response.BinaryWrite(). And it seems work.
The script sets image type as "Response.ContentType = 'image/JPEG';"
But viewing image properties in IE returns Type and Size as 'Not available'.
How to set these properties properly?
 
M

Mikhail Tchikalov

Try to turn response buffering on in the beginning of your script:
Response.Buffer = True
Response.ContentType = "image/jpeg"

Best regards,
Mikhail.
 
T

Tumurbaatar S.

The ASP script file which sends image looks like this:

<%@LANGUAGE="JScript" CODEPAGE="1252"%>
<%
var err = false;

Response.Clear();
Response.ExpiresAbsolute = 0;
Response.Expires = 0;
Response.AddHeader('pragma', 'no-cache');
Response.CacheControl = 'no-cache';
Response.ContentType = 'image/jpeg';
....
try
{
rec = cmd.Execute(c, params, adCmdText);
if (rec.EOF)
err = true;
else
{
Response.AddHeader('Content-Length', rec('PIC').ActualSize);
for (;;)
{
t = rec('PIC').GetChunk(1400);
if (t == null)
break;
Response.BinaryWrite(t);
Response.Flush();
}
}
}
catch (e)
{
err = true;
}
if (rec != null && rec.State == adStateOpen)
rec.Close();
if (con.State == adStateOpen)
con.Close();
con = cmd = rec = null;
}
if (err)
Response.Clear();
Response.End();
%>

The buffering is enabled by default.
And the image is received without a problem.
Only its _type_ and _size_ are unknown when looking
image properties (right-click on the image and Properties menu item)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,144
Messages
2,570,823
Members
47,369
Latest member
FTMZ

Latest Threads

Top