Re: Storing Image Location in MySQL
| From: | Sashikanth Gurram | Date: | Mon, 23 Feb 2009 03:59:42 +0000 |
| Subject: | Re: Storing Image Location in MySQL | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45996@lists.php.net to get a copy of this message | ||
Phpster wrote:
On Feb 22, 2009, at 5:17, Joao Gomes Madeira <jpcg.mad@gmail.com> wrote:I did not quite get what you have said. Does it really matter where we store the image? I mean, we can always retrieve the location and display it as long as we feed the db with the correct path. And what is meant by a image upload routine? -Sashi -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sashikanth Gurram Graduate Research Assistant Department of Civil and Environmental Engineering Virginia Tech Blacksburg, VA 24060, USAHey 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 <sashi34u@vt.edu> To: php-db@lists.php.net 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 |Note that the image needs to be accessible by apache. You may want to store those images in a folder in or just above the web root and perhaps create an image upload routine Bastien Hi Bastien,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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php