taketwodevelopment Posted September 20, 2008 Share Posted September 20, 2008 Hello all, Actually 2 quesitons here. 1. I have a client that has a system that he uses to store pictures in a mysql database, along w/ other things about the pictures. He now wants the pictures stored on a different box. I have a script I wrote to pull the images from the database and display them - but how can I pull them out and save them as a file? 2. The way the above said images get into the database, is someone wrote a crawler script for him that goes to several sites and pulls images off (he does have the sites permission to do so). After looking at the script- the person that wrote it gets the url of the image and then does a curl on it - then shoves the curl result into the database. Since I have the remote URL already, what is the best way to get that image stored on the box that the crawler is running on? Doing some searching, Im thinking to just do a imagecreatefromjpeg or gif, but Im not sure if the GD librarys are installed on that box. Im betting they are not. So if that is the case, could anyone offer other options? (please no flames about storing pics in the database, Im just trying to clean up someone elses mess) Thanks _Rob Link to comment https://forums.phpfreaks.com/topic/125040-how-to-save-an-image-stored-in-a-database/ Share on other sites More sharing options...
genericnumber1 Posted September 20, 2008 Share Posted September 20, 2008 how is the image stored? in a blob as the raw file data it sounds like that's what you're saying? if so, just do file_put_contents('some/file/path/image.jpg', $imageDataFromDatabase); // Don't use such a long variable name I don't understand your second question. Link to comment https://forums.phpfreaks.com/topic/125040-how-to-save-an-image-stored-in-a-database/#findComment-646167 Share on other sites More sharing options...
Lodius2000 Posted September 20, 2008 Share Posted September 20, 2008 for part 2: dunno it blob images need to be imagecreatefromjpegED but i have an upload script that if you provide a new name and use the rename() function it will save the file as that new name without any gd functions. Also, I wouldnt use the remote url, because there is no guarantee that the image is still in the remote location, so use whats in the db because it is there for sure. Link to comment https://forums.phpfreaks.com/topic/125040-how-to-save-an-image-stored-in-a-database/#findComment-646174 Share on other sites More sharing options...
waynew Posted September 20, 2008 Share Posted September 20, 2008 They shouldn't be stored in a database. In reality; they should be stored on the actual filesystem and referenced via the database. As far as I know, MySQL isn't that good at handling BLOBs. Link to comment https://forums.phpfreaks.com/topic/125040-how-to-save-an-image-stored-in-a-database/#findComment-646296 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.