Guest Posted August 28, 2012 Share Posted August 28, 2012 Hi Everyone, I'm not entirely sure how images would work with php. The images these types of websites have (below) do you believe the images are stored in a mysql database and called like everything else or are they stored differently? If so, how are they called? http://www.lotpro.com/cars/new/porsche/boxster/ http://www.lotpro.com/search/vehicleinfo/02921/all/all/0/999999/0/999999/5YMGY0C52CLK27716/yy0115/ Thanks Everyone! Quote Link to comment https://forums.phpfreaks.com/topic/267710-imagesphp-and-mysql-how-does-it-work/ Share on other sites More sharing options...
rythemton Posted August 28, 2012 Share Posted August 28, 2012 To be honest, it's really hard to tell how the images are stored. They could be stored as files that are directly accessed, or they could be stored as files that are indirectly accessed through a script, or they could be stored in a database as a 'blob' (binary large object) and accessed through a script. Your browser can't tell the difference, so it's hard to tell what process was used. If you have done everything correctly, it shouldn't matter how you have stored the images. I usually store the files in a locked directory so that they can't be accessed directly, then I use a PHP script to fetch the files. The only thing I store in the database is details about the file (height, width, original file name, etc.) and I don't store the files by their original name, that way I can guarantee that each file is uniquely named and doesn't overwrite other files. Quote Link to comment https://forums.phpfreaks.com/topic/267710-imagesphp-and-mysql-how-does-it-work/#findComment-1373331 Share on other sites More sharing options...
hakimserwa Posted August 28, 2012 Share Posted August 28, 2012 check this http://www.developphp.com/list_php_video.php#PHP_Image_Processing Quote Link to comment https://forums.phpfreaks.com/topic/267710-imagesphp-and-mysql-how-does-it-work/#findComment-1373338 Share on other sites More sharing options...
Psycho Posted August 28, 2012 Share Posted August 28, 2012 There's no way to tell from viewing a website how they handle images. There are several approaches. Here are a few: 1. In the database, store the Path and Name (or just name if all files are in the same directory) of the image which is stored on the server (or accessible to the server). Then when displaying information about the product you use that path/name to create an image tag using that path in the src attribute. 2. Actually store the image data in the database. This requires you to read all that data and create an image to return to the client. I think you can include the image directly in the HTML file, but it would be messy. A more common approach is to create an image tag as above and use a PHP file as the source with the image ID as a parameter. The PHP page would look up the image in the database and create the image to return to the HTML page. 3. Or you can just name the images using the ID of the record. So, if you have record with id 123456, just name the photo 123456.jpg. Then when displaying the record details you use the id to grammatically set the image name in the IMG tag. If you will ALWAYS have a one-to-one relationship between the record and the image, this will suffice. but I personally don't like it. My preference is #1. Storing images in the database is more overhead and is not worth the effort. There are a few narrow uses cases where it might make sense. but, they are few and far between. Quote Link to comment https://forums.phpfreaks.com/topic/267710-imagesphp-and-mysql-how-does-it-work/#findComment-1373420 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.