I've been using a table to store images, along with other info, but can now see the wisdom of storing the images in files rather than db tables.
I'm writing a script to read the images in and then write them back out to disk, but cannot get it to work correclty. When I use a script to read the image and display it everything works fine (this relies on calling an external file to read the image and set the header, etc.), but I can't quite see how to read it in and copy it back out without displaying it.
The copy command causes the following error: Warning: Unable to open 'ÿØÿà' for reading: No such file or directory in /blah/blah/dev_convertimages_1.php on line x
The code is below. Any suggestions would be appreciated.
// Connect to the database
// Form image directory string
$images_dir = "/blah/blah/marketdataimages/";
// Extract image from db
$x=1;
$result = mysql_query( "SELECT id, uniqueid, image FROM $dbtable where id=$x" );
$a_row = mysql_fetch_row($result);
list ($id, $uniqueid, $image) = $a_row;
$imagename = $uniqueid . ".jpg";
copy ($image, "$images_dir/$imagename");