tonelm54
asked on
img src
Im trying to put in an image source as:-
However inside html doesnt display the image, instead just displays the image as if it doesnt exist, however if I goto the location where getImgLogo.php exists and load it works fine.
Im assuming the issue is that src doesnt know its a png file so cant display it. Is this correct and if so how can I tell it there is a PNG coming in like:-
or is there another issue?
Thank you
<img src="../logos/getImgLogo.php?logoID=<?php echo $row['cid']; ?>" alt="Logo" />
However inside html doesnt display the image, instead just displays the image as if it doesnt exist, however if I goto the location where getImgLogo.php exists and load it works fine.
Im assuming the issue is that src doesnt know its a png file so cant display it. Is this correct and if so how can I tell it there is a PNG coming in like:-
<img src="data:image/png;../logos/getImgLogo.php?logoID=<?php echo $row['cid']; ?>" alt="Logo" />
or is there another issue?
Thank you
The problem is in your getImgLogo.php and not in your img tag. Please post the php code so that people can help.
The PHP page must return the correct MIME type in a header for the image type to be recognized. It also must be sent first before the image content.
header('Content-type: image/png');
Look at the first example on this page: http://php.net/manual/en/function.imagecreate.php
ASKER
Im trying to show the image as:-
And the to get the image (simplified code):-
Ive attached the code, in the hope someone can help, please
Thank you
index.php
showImage.php
2.png
<HTML>
<HEAD>
</HEAD>
<BODY>
<img src="showImage.php?logoID=3" />
</BODY>
</HTML>
And the to get the image (simplified code):-
<?php
if (file_exists($_GET['logoID'] . ".dat")) {
$filename = $_GET['logoID'] . ".dat";
} else {
$filename = "noLogo.dat";
}
$savename = $_GET['logoID'] . ".png";
header("Content-Type: image/png");
header("Content-Length: " . filesize($filename));
//header("Content-Disposition: attachment; filename=". $row['name']);
list($width, $height) = getimagesize($filename);
$newwidth = 50;
$newheight = 30;
$imgsrc = file_get_contents($filename);
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefrompng($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagepng($thumb);
imagedestroy($thumb);
imagedestroy($source);
?>
Ive attached the code, in the hope someone can help, please
Thank you
index.php
showImage.php
2.png
Works perfectly when you change "logoID=3" to "logoID=2" so it looks for the right image.
ASKER
Sorry, uploaded a some wrong test data.
Im a bit confused, as when I upload it to a testing server I get the image load then disapear in chrome???
For example:-
http://test.uwh.tonycross. me.uk/imgS rc/index.p hp
But image loads fine:-
http://test.uwh.tonycross. me.uk/imgS rc/showIma ge.php?log oID=2
Very confused now :-S
Im a bit confused, as when I upload it to a testing server I get the image load then disapear in chrome???
For example:-
http://test.uwh.tonycross.
But image loads fine:-
http://test.uwh.tonycross.
Very confused now :-S
No, your test site works just fine from here in Chrome and Firefox.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Found the problem myself, but thank you for your assistance
Open in new window
Cheers