Re: [PHP-DB] Storing Image Location in MySQL

[email protected] (Sashikanth Gurram)
Newsgroups php.db
Message-ID <[email protected]>
Hi JP,

Can you please let me know what is a GD? I have not installed Apache 
separately. I am using the WAMP server currently. Do I have to install 
any additional stuff  before I can retrieve the image location from the 
db and display it in my browser?

-Sashi

Joao Gomes Madeira wrote:
> Hey Sashi
>
> You want something similar to this:
> (you must have GD installed on Apache)
>
> you can have this working by doing something like this in HTML:
>
> <img src="picture.php?&qry=123">
>
> and having as picture.php:
>
> <?php
> ... get the record from the database using query string and then ...
>
> $err=1;
> if ($img = file_get_contents('/yourpath/yourfile.jpg', 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);
> }
> ...
>
> Cheers
> JP
>
>
> -----Original Message-----
> From: Sashikanth Gurram <[email protected]>
> To: [email protected]
> Subject: [PHP-DB] Storing Image Location in MySQL
> Date: Sun, 22 Feb 2009 03:43:06 -0500
>
> Dear All,
>
> I am trying to store the location of a image into MySQL database, so 
> that I can call it back from PHP to display it in a browser. For this 
> purpose, I have created a table with two columns (BuildingCode, 
> Location), where building is the primary key and location is the 
> location where my picture is stored on my PC. My image is stored at  
> /C:\Users\Sashikanth\Desktop\burruss.jpg/ on my PC.
> The following table is an output from MySQL.
> +--------------+-----------------------------------------+
> | BuildingCode   | Location                                                |
> +--------------+-----------------------------------------+
> | 176                 | c:/users/sashikanth/desktop/burruss.jpg   |
> +--------------+-----------------------------------------+
>
> Considering my original Image Location on my PC, will the above table be 
> of any help if I try to retrieve the image using PHP? Is there any 
> mistake in what I have done till now?
> I know that this may be a very basic question and i have searched 
> through the internet quite extensively but could not find a solid 
> answer. Would appreciate it greatly if anyone can help.
>
> Thanks,
> Sashi
>
>   


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sashikanth Gurram
Graduate Research Assistant
Department of Civil and Environmental Engineering
Virginia Tech
Blacksburg, VA 24060, USA
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.