Re: Retrieving Image Location in MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi JP,
Thanks for chipping in again. I have been using the following code (after retrieving the local location of my image to the variable $location. I am not really looking to host the pictures onto a site as of now), which u have earlier provided me with
/
$err=1;
if ($img = file_get_contents("$location", FILE_BINARY))
{
 if ($img = imagecreatefromstring($img)) $err = 0;
}
if ($err)
{
 header('Content-Type: text/html');
echo '<html><body><p style="font-size:9px">Error getting image...</p></body></html>';
}
else
{
 header('Content-Type: image/jpeg');
 imagejpeg($img);
 imagedestroy($img);
}
/
I am just using this and nothing more, and I have been getting a warning of sort "CANNOT MODIFY HEADER INFORMATION-HEADERS ALREADY SENT ......ON LINE 234". I have looked about this warning online and i found that this occurs when the output is sent to the browser before the headers. From the look of the above code, I dont think I am sending the info to the browser before the headers. Also, when I use the above code, I see a lot of ASCII characters in my browser. May be, the image is encrypted into some form and the encrypted form is being displayed instead of the picture. Further, you have always mentioned about using

img src="picture.php?&img=1234. I did not clearly understand where to put it in the code. Is it a part of HTML code or is it a part of PHP code?


Thanks,
Sashi



Joao Gomes Madeira wrote:
Hello again Sashi

The answer provided by Mushin won't work because images are not
acessible from the outside. You can't have

<img src="C:\Users\Sashikanth\Desktop\Bldgs_lots\Burruss.jpg" ...>

because that's not a valid URL...

You can have something like

<img src="Bldgs_lots/Burruss.jpg" ...>

which when interpreted by the browser will become something like

http://yoursite/Bldgs_lots/Burruss.jpg

Now, for this to happen you need to have Bldgs_lots as a subfolder or
alias for your site.

Otherwise, there is the way I mentioned in the first place, involving a
php script just to get the image, which has to be called from within
your script, passing it the info from the database

echo '<img src="picture.php?&img=' . $location . '" border="1" height="150" width="200" alt="' . $build . '">';

Now, I don't recommend passing local paths like this to scripts ...

Hope this helps
C ya
JP




--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sashikanth Gurram
Graduate Research Assistant
Department of Civil and Environmental Engineering
Virginia Tech
Blacksburg, VA 24060, USA


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux