Commit | Line | Data |
---|---|---|
fd25bf87 JC |
1 | <?php |
2 | $id = array_shift($pieces); | |
3 | ||
4 | if (empty($id)) { | |
5 | header('HTTP/1.0 400 Bad Request'); | |
6 | die('400 Bad (Empty) Request'); | |
7 | } | |
8 | ||
9 | require_once __DIR__ . '/db.php'; | |
10 | ||
11 | $db = get_db(); | |
12 | $fetch_stmt = $db->prepare('SELECT | |
13 | pi.ID, pi.MIME_TYPE, pi.PIC_B64 | |
14 | FROM pics pi | |
15 | WHERE pi.ID = :id'); | |
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']; | |
21 | $pic_id = $pic['ID']; | |
22 | header("Content-Type: {$mime_type}"); | |
23 | die(base64_decode($file_b64, true)); | |
24 | } | |
25 | header('HTTP/1.0 404 Not Found'); | |
26 | die('404 File Not Found'); | |
27 | ?> |