I've gone through all kinds of hoops trying to get this to work and to avail had I any luck.

The problem: when I use IE and right click on the image and select Properties, none of the properties are getting their values (i.e. File Size, Type, Created modified, etc.). However, Address, Protocol and Dimensions are coming up.

The high level of the code is very simple;
1. Do basic session management
2. Open DB connection
3. Get Image and its params
4. Dump the image params (headers)
5. Send the bit stream

And yes this is a seperate file that is sending the image and not embedded in the same HTML file. Any thoughts what may be causing this?

Here is some of the code:
//imports for items 1& 2 above
require_once ("constants.php");
require_once ("dbConnect.php");
require_once ("errorLogger.php");

...

//item 3 from above
while($row = @mysql_fetch_object($dbResult)) {
$lengths = mysql_fetch_lengths($dbResult);
$binData = $row->image_large;
}

...

//items 4 & 5 from above
header("Accept-Ranges: bytes");
//header("ETag: \"2dc012-97c-3e112287\"");
header("Content-disposition: inline; filename=dd.jpg");
header("Content-length: $fileSize");
header("Content-type: image/jpeg");
//header("Last-Modified: Tue, 31 Dec 2002 04:52:23 GMT");
print ("$binData");

I've played with many header types to see if I can bring any changes and had no luck. Any thoughts or solutions to this would be greatly appreciated... time for some Motrin now 😉

    Okay, after going through hell for the past several days, a day or two after I post on the board I found the answer for myself 😉

    So here it is for those who are having the same problems. Just be sure the following headers are being set with the most important being the Cache-control being set to public (or to what is needed).

    Final code:
    header('Cache-Control: public', TRUE);
    header("Last-Modified: Tue, 31 Dec 2002 04:52:23 GMT");
    header('Content-Transfer-Encoding: base64', TRUE);
    header("Accept-Ranges: bytes", TRUE);
    header("Content-Length: $fileSize", TRUE);
    header("Content-Disposition: inline; filename=dd.jpg", TRUE);header('Content-Type: image/jpeg; filename="dd.jpg"', TRUE);

    print ($binData);

    Now I have all the information available when I do a properties on the image 😉

    COOL CODE IMPLEMENTATION FOR THOSE WHO CARE
    What I did is add an apache handler in my httpd.conf file. Now when I hit a certain directory, a handler is called and redirected to another page (a php script). That script grabs the referring URL which also contains the image name. I can grab the image and use it as params for my image get method from the db. The cool thing about doing this is that my URL look like:
    /images/apacheHandler/key_20.jpg
    where key can be a trigger in your code to get a certain type of image from the db and the number is the ID of that image.

    Why do this, one, you image URLs in the image src are cleaner and look somewhat more like real image tags. More importantly, proxy servers and local caches actually work. I believe URLs with aprams don't cache to nicely. The old way to do the above would have been... perhaps...
    /getImageScript.php?type=thumbPerson&id=20

    If someone is remotely interested in my implementation, let me know and I'll post the solution.

      Write a Reply...