| 1 | <?php |
| 2 | |
| 3 | require_once __DIR__ . "/lib/recibeEnteroObligatorio.php"; |
| 4 | require_once __DIR__ . "/lib/validaEntidadObligatoria.php"; |
| 5 | require_once __DIR__ . "/Bd.php"; |
| 6 | |
| 7 | |
| 8 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
| 9 | header("Cache-Control: post-check=0, pre-check=0", false); |
| 10 | header("Pragma: no-cache"); |
| 11 | |
| 12 | $archId = recibeEnteroObligatorio("id"); |
| 13 | |
| 14 | $bd = Bd::pdo(); |
| 15 | |
| 16 | $stmt = $bd->prepare("SELECT * FROM ARCHIVO WHERE ARCH_ID = :ARCH_ID"); |
| 17 | $stmt->execute([":ARCH_ID" => $archId]); |
| 18 | $archivo = $stmt->fetch(PDO::FETCH_ASSOC); |
| 19 | |
| 20 | $archivo = validaEntidadObligatoria("Archivo", $archivo); |
| 21 | |
| 22 | $bytes = $archivo["ARCH_BYTES"]; |
| 23 | $contentType = (new finfo(FILEINFO_MIME_TYPE))->buffer($bytes); |
| 24 | header("Content-Type: $contentType"); |
| 25 | echo $bytes; |
| 26 | |