Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Tried all solution but failed to display an image

images php coding issues or problems here.

Moderators: macek, egami, gesf

Tried all solution but failed to display an image

Postby kamal444 » Sun Mar 27, 2005 9:13 am

I thought that displaying image in PHP was easy; but i am having a lot of problem simply displaying a gif file.

The code is here:

<html>
<head>
</head>
<body>
<?php
$img = "C:\Inetpub\wwwroot\gps1\mumbai.gif";
$im = imagecreatefromgif ($img);
header( 'Content-type: image/gif' );
imagegif($im);
?>
</body>
</html>

I don't know what is the problem.
I have saved the text file in ANSI format.
Also, I have tried various changes in php.ini file but the error that headers already sent out was only solved when output_buffer was ON.

Also, the php_gd2.dll extension is enabled.

In the IE 6 , i get the whole image as garbled like
GIF87SASDFSAF.......

Something like this.

I have tried in other browsers like netscape and Firefox.

Also, please note I am using IIS 5 server.

Please can any one help.
kamal444
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Mar 27, 2005 9:02 am

Postby ruturajv » Mon Mar 28, 2005 10:05 pm

Code: Select all
<html>
<head>
</head>
<body>
<?php
$img = "C:\Inetpub\wwwroot\gps1\mumbai.gif";
$im = imagecreatefromgif ($img);
header( 'Content-type: image/gif' );
imagegif($im);
?>
</body>
</html>

you can't do both (displaying HTML and rendering image) in a single page...
you have to do... image display ie content-type: image/png
in a different page.
and then call that page in img tag
Code: Select all
<img src="image.php?id=someid" />
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Gott it.

Postby kamal444 » Tue Mar 29, 2005 5:47 am

Thanks for the help.

I got the display.

You did a great favor, I was working on this for nearly 2 days.

If you could post, som edocs avail other than at php.net

Regards,
Kamal.
kamal444
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Mar 27, 2005 9:02 am


Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 6 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.