I can get a BLOB image from my MySQL database but I want to show it as a preview image when I post to facebook. I don't want to save the image to my computer because I will end up with too many images. The closest I can get is showing a load of ascii code instead of the actual image. Is it even possible to achieve this? This is the code I have at the moment.
<?php
require_once($_SERVER['DOCUMENT_ROOT']."/includes/config.php");
$keys = htmlspecialchars($_GET['id']);
$query = "SELECT * FROM birdtabletop WHERE id='$keys' AND approvalMsg = 'Approved' LIMIT 1";
if(!isset($error)){
try {
foreach ($db->query($query) as $row) {
//set vars here
$tTitle = $row['tabletop_name'];
$tPicture = $row['tabletop_photo'];
}
} catch(PDOException $e) {
header('Location: login.php');
}
}
if(!isset($row)){
header('Location: login.php');
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<?php include_once("includes/analyticstracking.php") ?>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php echo $tTitle; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="">
<meta property="og:title" content="<?php echo $tTitle; ?>">
<meta property="og:type" content="website">
<meta property="og:url" content="https://www.finchkeeper.com/viewtabletop.php<?php echo "
?id=".htmlspecialchars(filter_input(INPUT_GET, 'id')); ?>">
<?php
if($tPicture != NULL){
echo '<meta property="og:image" content="data:image/jpeg;base64,'.base64_encode( $tPicture ).'"/>';
}else{
echo '<meta property="og:image" content="https://www.finchkeeper.com/images/tabletop.jpg">';
}
?>
<meta property="og:description" content="" />