Dave J-2 wrote:
> 
> 
> try setting
> $this->autoRender = false     (instead of setting the layout to
> empty), this way Cake won't send anything out to the browser.
> 
> also, you might want to try:
> header('Content-Type: image/jpeg');
> (notice the 'jpeg' instead of 'jpg')
> 
> 

Hey Dave, thanks for the suggestions. Sorry for the delayed reply. I posted
this on Google Groups and had no idea how to find it! 

So I gave your suggestions a try---I also threw in an exit(200) to replace
the die(), just for kicks but the problem persists.

<code>
    Configure::write('debug', 0);
    $this->autoRender = false;
    $file = APP . 'uploads' . DS . 'memorials' . DS . $id . DS . 'photos' .
DS . 'thumbs' . DS . $file_name;
    header('Content-Type: image/jpeg');
    header('Content-Length: ' . filesize($file));
    readfile($file);
    exit(200);
</code>

So, in FF the result I see displayed in the browser is simply the requested
URL: http://devel.domain.com/controller/displayFile/4/2.jpg/thumb. However
if I "view source" I see what looks to be the content of the image (just a
snippet below):
ÿØÿà� JFIF�  �� � ��ÿþ�;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality
= 75 ÿÛ�C�          

I went to bed last night thinking about what may potentially be causing this
problem---didn't come up with much. I _can_ view images successfully using
the readfile() method with a test script that does not involve CakePHP so
I'm still inclined to think Cake is the culprit. But what would Cake be
doing other than adding headers---which from my original post seem to check
out ok. I'm still stumped.

If I force a download of the file with:
header('Content-Disposition: attachment; filename="' . basename($file) .
'";');
I can successfully view the file in Photoshop however if I open the
downloaded file using FF the same result is produced where I only see the
path to the image displayed:
file:///C:/Documents%20and%20Settings/Administrator/Desktop/2.jpg
and the "view source" shows the image file's contents. I'm not sure what
that tells me though...
-- 
View this message in context: 
http://www.nabble.com/Problems-displaying-an-image-from-a-controller-action-using--readfile%28%29-tp17443713p17458274.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to