Reply to Re: PHP-gen'd images won't display in HTML

Your name:

Reply:


Posted by Dr. No on 01/04/07 22:58

Webtechnics - Info wrote:
> I also had this problem, I can;t remember exactly how i solved it, but i
> remember that you CAN'T set the image-source to a .php file.
>
> If i now more, i'l let you know.
>
>
>

Yea, that simply isn't correct. I use .php files to send images with no problem.
The PHP script simply needs to generate the correct header before it writes any
data. For a JPEG, you'd include a line like this in your script:

header ('Content-Type: image/jpeg');


If your script is called foo.php, you can load the image like this:

<img src="foo.php" alt="A dynamic image." />

The browser will use the header rather than the extension to determine the file
type. PHP can pass any type of data to the browser using this method. One
application I wrote passes Word, Excel, PDF, HTML, JPEG, GIF, and PNG files
through the same wrapper script, and could pass anything that has a mime type by
placing the correct mime type into the database. PHP can output just about
anything to a web browser.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация