l0ve2hat3 Posted April 15, 2008 Share Posted April 15, 2008 I have pictures already uploaded in a folder in a server. What I need to do is convert the files to store them in a mysql database. could I use file_get_contents to do this? Link to comment https://forums.phpfreaks.com/topic/101153-storing-pics-in-mysql/ Share on other sites More sharing options...
Northern Flame Posted April 15, 2008 Share Posted April 15, 2008 what you do is store the names in your database and then use a mysql_query() to get the names from your database then just echo something like this: $query = mysql_query("SELECT * FROM images"); while($image = mysql_fetch_object($query)){ echo "<img src='/folder/". $image->name ."' />"; } Link to comment https://forums.phpfreaks.com/topic/101153-storing-pics-in-mysql/#findComment-517384 Share on other sites More sharing options...
Rohan Shenoy Posted April 15, 2008 Share Posted April 15, 2008 Its difficult to store image files in the MySQL database. Instead just save the url of the image and retrive it as Northen Flame directed in above post. Link to comment https://forums.phpfreaks.com/topic/101153-storing-pics-in-mysql/#findComment-517392 Share on other sites More sharing options...
benphp Posted April 15, 2008 Share Posted April 15, 2008 From what I understand, this is a bad idea. It's possible to do it, but not at all the best way to manage images. Use the above suggestion about storing just the filename/path. Link to comment https://forums.phpfreaks.com/topic/101153-storing-pics-in-mysql/#findComment-517395 Share on other sites More sharing options...
rameshfaj Posted April 15, 2008 Share Posted April 15, 2008 There is one alternative to the above mentioned ideas.You can make the database field to hold BLOB rather than varchar and when u store the image in the database it will be stored in binary format.There are many tutorials online about storing BLOB object in database,why dont u try one? Link to comment https://forums.phpfreaks.com/topic/101153-storing-pics-in-mysql/#findComment-517472 Share on other sites More sharing options...
Guest Posted April 15, 2008 Share Posted April 15, 2008 yep i just went through one of these tutorials about storing images in mysql in BLOB format i also saw a script that will do exactly what you want: take all images you have in a folder and put them in database just search on google with revealent keywords and you will find it Link to comment https://forums.phpfreaks.com/topic/101153-storing-pics-in-mysql/#findComment-517475 Share on other sites More sharing options...
benphp Posted April 15, 2008 Share Posted April 15, 2008 I'm still not sure why you would want to store the images IN the database. There must be a reason, but I can't think of one. If you do, and your images are large, or there are a lot of them, you're asking for trouble. Link to comment https://forums.phpfreaks.com/topic/101153-storing-pics-in-mysql/#findComment-517682 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.