You are here: passing a filename & content type as image « PHP Programming Language « IT news, forums, messages
passing a filename & content type as image

Posted by B Squared on 01/26/06 21:13

I'm trying to pass a filename (which is a jpeg image) to a php
function / file so that it will display. I know that its simple
to get PHP to display an image hardcoding in the filename. For
example, an href to this:

<?php
header("content-type:image/jpeg");
$filename = "image_file.jpg";
$im=ImageCreateFromJPEG($filename);
ImageJPEG($im);
?>

But when I have a filename I create dynamically in PHP and try to
call a php function with the filename, for example calling:

<?php
display_jpeg_file($image_path);
?>

<?php
function display_jpeg_file($filename) {
header("content-type:image/jpeg");
$im=ImageCreateFromJPEG($filename);
ImageJPEG($im);
}
?>

I get the "cannot modify header information" error. The error
message always refers to a php function early in the phmtl page.
So somehow it sees this function as a continuation of the existing
html document. How do I arrange the function call to my display
function so that it works? Or, if my approach is all wrong, what
is the correct approach? The important part is I have a filename
generated in PHP that I want to display.

Thanks in advance for any help.

B Squared

===============================================================
Self esteem, n. An erroneous appraisement
-- Ambrose Bierce, The Devils Dictionary

 

Navigation:

[Reply to this 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

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