-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocument.php
More file actions
26 lines (26 loc) · 779 Bytes
/
document.php
File metadata and controls
26 lines (26 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
// ParcSivom ©HPSdevs@gmail.com
// Fichier de lecture de documents
$url = PARSE_URL($_SERVER['REQUEST_URI']);
$id = (int) $url['query'];
if ($id) {
require_once("./controllers/ctrl-document.php");
$document = CallFilenameDoc($id) ?? null;
if ($document) {
$file = "Documents/" . $document['filename'];
$mine = mime_content_type($file);
switch ($mine) {
case 'application/pdf':
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $file . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
@readfile($file);
break;
default:
header("Content-type: " . $mine);
readfile($file);
break;
}
}
}