Re: Retrieving Image Location in PHP from MySQL
| From: | Nathan Nobbe | Date: | Sun, 08 Mar 2009 05:12:43 +0000 |
| Subject: | Re: Retrieving Image Location in PHP from MySQL | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289581@lists.php.net to get a copy of this message | ||
On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram <sashi34u@vt.edu> wrote:
> The thing is, I do not have a website or a place where I am storing my
> images. I am storing the images on my local PC in folder as mentioned in my
> earlier post. I have tried using only the
>
> else {
> header('Content-Type: image/jpeg');
> imagejpeg($img);
> imagedestroy($img);
> }
>
> Which you have suggested. This is the piece of code which is returning all
> the binary character stuff. The code is definitely fetching the image. But
> it is not able to deliver to the browser in the form of an image. I am
> trying to read the image file as binary, evident from the FILE_BINARY
> command. So may be, that is causing the image to be displayed as binary. Is
> there any way we can convert the binary content to jpeg/jpg content again.
> This is my guess after having gone through the code again.
i spent 2 minutes working on it and read this in the manual,
the first param of imagejpeg(),
An image resource, returned by one of the image creation functions, such as
imagecreatetruecolor()<http://us.php.net/manual/en/function.imagecreatetruecolor.php>
.
so, then i tossed this together,
http://nathan.moxune.com/echoImage.php
<?php
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg('./phpLogo.jpeg'));
-nathan