Skip to content

Instantly share code, notes, and snippets.

Created Apr 21, 2021
What would you like to do?
Save Image File with PHP & MySQL - #4
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