Hey i have upload an image on my database (mysql) and i want to retrieve the blob image on a specific size.
until now with this code i can fully retrieve the image on the same dimensions that i have uploaded.
The uploaded image has the dimensions 1024X728.
I want the new image to have the dimensions 200X150.
Thank you
<?php
require_once('connection.php');
try {
if (!isset($_GET['id'])) {
throw new Exception('ID not specified');
}
$id = (int) $_GET['id'];
if ($id <= 0) {
throw new Exception('Invalid ID specified');
}
$query = sprintf('select * from images where image_id = %d', $id);
$result = mysql_query($query, $db);
if (mysql_num_rows($result) == 0) {
throw new Exception('Image with specified ID not found');
}
$image = mysql_fetch_array($result);
}
catch (Exception $ex) {
header('HTTP/1.0 404 Not Found');
exit;
}
header('Content-type: ' . $image['mime_type']);
header('Content-length: ' . $image['file_size']);
echo $image['file_data'];
?>