2 $id = array_shift($pieces);
5 header('HTTP/1.0 400 Bad Request');
6 die('400 Bad (Empty) Request');
9 require_once __DIR__
. '/db.php';
12 $fetch_stmt = $db->prepare('SELECT
13 pi.ID, pi.MIME_TYPE, pi.PIC_B64
16 $fetch_stmt->bindValue(':id', $id);
17 $result = $fetch_stmt->execute();
18 if ($pic = $result->fetchArray()) {
19 $mime_type = $pic['MIME_TYPE'];
20 $file_b64 = $pic['PIC_B64'];
22 header("Content-Type: {$mime_type}");
23 die(base64_decode($file_b64, true));
25 header('HTTP/1.0 404 Not Found');
26 die('404 File Not Found');