Re: Storing Image Location in MySQL
| From: | Sashikanth Gurram | Date: | Mon, 23 Feb 2009 03:53:23 +0000 |
| Subject: | Re: Storing Image Location in MySQL | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45994@lists.php.net to get a copy of this message | ||
Thanks fir the suggestion Chris
-Sashi
Chris wrote:
Sashikanth Gurram wrote:-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sashikanth Gurram Graduate Research Assistant Department of Civil and Environmental Engineering Virginia Tech Blacksburg, VA 24060, USADear 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 |Don't store the full path to the image, just store the relative path. If you move your app to a new folder, then you have to go through and update all database records to point to the new path. If you store the relative path, you can set a config variable (or work it out yourself), and add the relative path to the end. So in your config: $cfg['folder_name'] = 'c:/apps/my_app_name/'; in the db location will be 'images/image.jpg'; Put the two together to get the full path: $image_path = $cfg['folder_name'] . $db['location'];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.