IE8 doesn't know how to handle image link

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iG9
Forum Commoner
Posts: 38
Joined: Fri Jul 18, 2008 2:11 pm

IE8 doesn't know how to handle image link

Post by iG9 »

Here's the way I'm displaying some images. All images with a common attribute get displayed in a table with proplist.php. If you click one of them it opens full size. The image is generated by viewprop.php. It works in ff, but ie doesn't know what to do with the image link and asks if you want to save it or find a program online to open it. Here's the code:

proplist.php

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>Luxury Maui Property</title>
        <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js'></script>
        <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js'></script>
        <script type='text/javascript' src='js/lightview.js'></script>
        <link rel="stylesheet" href="css/lightview.css" type="text/css" media="screen" title="no title" charset="utf-8" />
    </head>
    <body>
<?php
    include '../lmp_includes/lmp_utilities.php';
    $db = db_connect();
    
    if ($_GET['mls']) {
        $mls = mysql_real_escape_string($_GET['mls']); //these five get the propID
        $q = "select propID from properties where mls = $mls";
        $r = mysql_query($q);
        $d = mysql_fetch_object($r);
        $id = $d->propID;
        
        $q = "select * from images where propID = $id"; //these three lines get num rows
        $r = mysql_query($q);
        $numImages = mysql_num_rows($r);
        
        $d = mysql_fetch_assoc($r);
        echo "<table><td>";
        for ($i = 0; $i < $numImages; $i++) {
                if (($i!=0) && !($i%4)) {
                    echo "</td><tr></tr><td>";
                }
                echo "<a href=\"viewprop.php?mls=$mls&offset=$i\"><img src=\"viewprop.php?mls=$mls&offset=$i\" height=\"150px\" width=\"200px\"/></a>";
        }
        echo "</td></table>";
    } else {
        echo "I need an ID.";
    }
?>
    </body>
</html>
 
viewprop.php

Code: Select all

 
<?php
    include '../lmp_includes/lmp_utilities.php';
    $db = db_connect();
    
    if ($_GET['mls'] || $_GET['offset']) {
        $mls = mysql_real_escape_string($_GET['mls']);
        $offset = mysql_real_escape_string($_GET['offset']);
        $q = "select propID from properties where mls = $mls";
        $r = mysql_query($q);
        $d = mysql_fetch_object($r);
        $id = $d->propID;
        header('Content-type: image/jpg');
        $q = "select * from images where propID = $id limit $offset, 1";
        $r = mysql_query($q);
        $d = mysql_fetch_object($r);
        echo $d->image;
    } else {
        echo "I need both an mls and an offset.";
    }
?>
 
Any help is greatly appreciated.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: IE8 doesn't know how to handle image link

Post by jackpf »

I don't think IE understand image/jpg as a content type. It has to image/pjpeg I believe. (don't ask me why)
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: IE8 doesn't know how to handle image link

Post by JAB Creations »

Try the following...

Code: Select all

<?php echo $_SERVER['HTTP_ACCEPT'];?>
I use the following file for local testing for quick reference...

Code: Select all

<?php
echo '<div>'.$_SERVER['PHP_SELF'].'</div>';
echo '<div>'.$_SERVER['argv'].'</div>';
echo '<div>'.$_SERVER['argc'].'</div>';
echo '<div>'.$_SERVER['GATEWAY_INTERFACE'].'</div>';
echo '<div>'.$_SERVER['SERVER_ADDR'].'</div>';
echo '<div>'.$_SERVER['SERVER_NAME'].'</div>';
echo '<div>'.$_SERVER['SERVER_SOFTWARE'].'</div>';
echo '<div>'.$_SERVER['SERVER_PROTOCOL'].'</div>';
echo '<div>'.$_SERVER['REQUEST_METHOD'].'</div>';
echo '<div>'.$_SERVER['REQUEST_TIME'].'</div>';
echo '<div>'.$_SERVER['QUERY_STRING'].'</div>';
echo '<div>'.$_SERVER['DOCUMENT_ROOT'].'</div>';
echo '<div>'.$_SERVER['HTTP_ACCEPT'].'</div>';
echo '<div>'.$_SERVER['HTTP_ACCEPT_CHARSET'].'</div>';
echo '<div>'.$_SERVER['HTTP_ACCEPT_ENCODING'].'</div>';
echo '<div>'.$_SERVER['HTTP_ACCEPT_LANGUAGE'].'</div>';
echo '<div>'.$_SERVER['HTTP_CONNECTION'].'</div>';
echo '<div>'.$_SERVER['HTTP_HOST'].'</div>';
echo '<div>'.$_SERVER['HTTP_REFERER'].'</div>';
echo '<div>'.$_SERVER['HTTP_USER_AGENT'].'</div>';
echo '<div>'.$_SERVER['HTTPS'].'</div>';
echo '<div>'.$_SERVER['REMOTE_ADDR'].'</div>';
echo '<div>'.$_SERVER['REMOTE_HOST'].'</div>';
echo '<div>'.$_SERVER['REMOTE_PORT'].'</div>';
echo '<div>'.$_SERVER['SCRIPT_FILENAME'].'</div>';
echo '<div>'.$_SERVER['SERVER_ADMIN'].'</div>';
echo '<div>'.$_SERVER['SERVER_PORT'].'</div>';
echo '<div>'.$_SERVER['SERVER_SIGNATURE'].'</div>';
echo '<div>'.$_SERVER['PATH_TRANSLATED'].'</div>';
echo '<div>'.$_SERVER['SCRIPT_NAME'].'</div>';
echo '<div>'.$_SERVER['REQUEST_URI'].'</div>';
echo '<div>'.$_SERVER['PHP_AUTH_DIGEST'].'</div>';
echo '<div>'.$_SERVER['PHP_AUTH_USER'].'</div>';
echo '<div>'.$_SERVER['PHP_AUTH_PW'].'</div>';
echo '<div>'.$_SERVER['AUTH_TYPE'].'</div>';
?>
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: IE8 doesn't know how to handle image link

Post by jackpf »

But IE sends */* as its accept header, when it obviously supports nowhere near everything.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: IE8 doesn't know how to handle image link

Post by JAB Creations »

IE7...
*/*

IE8...
image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, application/x-shockwave-flash, */*

:wink:
iG9
Forum Commoner
Posts: 38
Joined: Fri Jul 18, 2008 2:11 pm

Re: IE8 doesn't know how to handle image link

Post by iG9 »

Thanks for the help everybody. jackpf, that worked. =)
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: IE8 doesn't know how to handle image link

Post by jackpf »

Cool.

That's weird though, because IE8 says it accepts image/jpeg and image/pjpeg.

Maybe it was just because you used jpg...maybe it has to be jpeg?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: IE8 doesn't know how to handle image link

Post by JAB Creations »

The only time I've ever encounter mime issues (besides IE and application/xhtml+xml) is when I pay attention to Safari's error console; I've never seen the other browsers have any issues (spit out errors/warnings) and Ie will simply give you the save file prompt.

Try commenting out the header on line 13 and see if it functions correctly, it may be an unnecessary step. :)
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: IE8 doesn't know how to handle image link

Post by jackpf »

I doubt that would work. Apache would send the default header for php, whatever that is. So you'll just see a load of binary or something.
Post Reply