Skip to content

Instantly share code, notes, and snippets.


codingwithsara/image.php Secret

Created Mar 16, 2019
What would you like to do?
How to Save Image File with PHP & MySQL - #5 Display images
require_once 'functions.php';
$pdo = connectDB();
$sql = 'SELECT * FROM images WHERE image_id = :image_id LIMIT 1';
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':image_id', (int)$_GET['id'], PDO::PARAM_INT);
$image = $stmt->fetch();
header('Content-type: ' . $image['image_type']);
echo $image['image_content'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment