Is this possible with php and a mysql database to Convert a blob into an image file?
In my case i had to use base64_decode to convert blob images correctly into file.
$path = "/tmp/images";
$sql = "SELECT image_name, image_content FROM images";
$result = mysql_query($sql, $db_con);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $sql;
die($message);
}
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$image = $row["image_contents"];
$name = $row["image_name"];
// option 1
$file = fopen($path."/".$name,"w");
echo "File name: ".$path."$name\n";
fwrite($file, base64_decode($image));
fclose($file);
// option 2 (oneliner)
// file_put_contents($path."/".$name, base64_decode($image));
}