Skip to content

Instantly share code, notes, and snippets.

@codingwithsara codingwithsara/image.php Secret
Created Apr 5, 2019

Embed
What would you like to do?
Save Image File with PHP & MySQL - #4
<?php
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);
$stmt->execute();
$image = $stmt->fetch();
header('Content-type: ' . $image['image_type']);
echo $image['image_content'];
unset($pdo);
exit();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.