-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
32 lines (31 loc) · 1002 Bytes
/
test.php
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
27
28
29
30
31
32
<?php
$outFile = $_GET["file"];
if(file_exists($outFile)){
echo "Hello";
if ($fd = fopen ($outFile, "r")) {
$fsize = filesize($outFile);
$path_parts = pathinfo($outFile);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "pdf":
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a file download
break;
// add more headers for other content types here
default;
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
break;
}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
}
else{
echo "Some error occured";
}
?>