Hi Don,
in this case, the problem might be, that there is some trailing space
(spaces, tabs, new lines) _after_ the closing ?>, so this is sent out
plain. After that, PHP isn't able to set a header (needed for the
content-type in your case), because the body has already been started.
If you don't close the PHP script part, it will be closed by PHP itself,
so there isn't any trailing space and your script is able to send the
header correctly.
So be careful, everything outside the PHP-tags <?php ... ?> is sent out
as plain HTML - as part of the body.
Regards,
Matthias
Don Reeves schrieb:
Lee, Andrew, and Ken,
Thanks for the help. It looks like the problem originated in a config
file that I wrote in php. I removed the closing '?>' and now my
images are being displayed correctly.
-D
----- Original Message ----
From: Ken Stanley <[EMAIL PROTECTED]>
To: Don Reeves <[EMAIL PROTECTED]>; [email protected]
Sent: Tuesday, December 26, 2006 2:42:23 PM
Subject: Re: [fw-general] dynamic image generation
Good day. I've been watching the list for a little while now, but I
think now would be a good time to jump in with a suggestion.
Don, I am going to assume that you are not viewing a 'typical' web
page (one that contains HTML, etc), but instead you are trying to view
the script itself that is trying to generate the image. If this is the
case, then there is no source to view as aforementioned by Lee. What
you can try to do is to turn on E_ALL error reporting, and then
comment out the line of code you are using to output the Content-Type
for your image. If there are errors, this should allow you to see
them, along with the contents of the image itself. When you set an
image header, the web browser doesn't treat it like a typical file,
therefor in most cases -- at least the ones I've dealt with -- you
won't see your PHP errors in the output.
I hope this helps. :)
On 12/26/06, *Don Reeves* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
I have actually tried to 'view source' but the option is not
available when I am viewing this page.
----- Original Message ----
From: Lee Saferite < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
To: Don Reeves <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>;
Zend Framework General < [email protected]
<mailto:[email protected]>>
Sent: Tuesday, December 26, 2006 8:17:56 AM
Subject: Re: [fw-general] dynamic image generation
Generally, in firefox, you can 'view source' and get the actual
error message the server sent.
Send us that error please.
Lee
On 12/25/06, * Don Reeves* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hi,
I am new to the Zend Framework but am very happy with what I
have seen so far. I have decided to try integrating the
framework into an application that I wrote previously. Things
have been going smoothly except for some scripts that I have
written to handle dynamically displaying images. These
images are charts that I use in the application. Here is a
script that I have converted into a controller in my
application. I access it from a url in the following manner:
http://localhost/chart/index/dir/dir123/file/chart123.gif
<http://localhost/chart/index/dir/dir123/file/chart123.gif>
The controller is pretty basic at the moment:
class ChartController extends Zend_Controller_Action
{
function indexAction()
{
$runDir = $this->_getParam('dir');
$file = $this->_getParam('file');
header("Content-type: image/gif");
$image = imagecreatefromgif(RUNS_DIR . '/' . $runDir . '/'
. $file);
imagegif($image);
imagedestroy($image);
}
}
An almost identical script allowed me to generate the gif
images previously. I have also confirmed that the image
referenced in imagecreatefromgif is referencing a valid gif file.
When I access the url
http://localhost/chart/index/dir/dir123/file/chart123.gif
<http://localhost/chart/index/dir/dir123/file/chart123.gif>, I
get the following message:
"The image "
http://localhost/chart/index/dir/dir123/file/chart123.gif
<http://localhost/chart/index/dir/dir123/file/chart123.gif>"
cannot be displayed, because it contains errors."
I am curious if there is anything about the Zend Framework
that prevents this image from displaying correctly. I was
wondering if it had to do with how I am setting my header but
examining the header using Tamper Data for Firefox, the
headers seem to be getting set correctly. Can anyone see a
problem with my implementation that needs to change to
generate images dynamically within the ZF?
Thanks for the help.
D
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
It looked like something resembling white marble, which was
probably what it was: something resembling white marble.
-- Douglas Adams, "The Hitchhikers Guide to the Galaxy"
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com