-
-
Save codeforfun-jp/681c3f8f0f145b6c6a0e869002efdf1b to your computer and use it in GitHub Desktop.
Save Image File with PHP & MySQL - #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']; | |
exit(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment