r4178 bugfix: PHP warnings were appearing before rackspace on SLB object page, defaul...
[racktables] / download.php
1 <?php
2 ob_start();
3 try {
4 require 'inc/init.php';
5 // purely for renderAccessDenied()
6 require 'inc/interface.php';
7
8 assertUIntArg ('file_id');
9 $pageno = 'file';
10 $tabno = 'download';
11 fixContext();
12 if (!permitted())
13 renderAccessDenied();
14
15 $asattach = (isset ($_REQUEST['asattach']) and $_REQUEST['asattach'] == 'no') ? FALSE : TRUE;
16 $file = getFile ($_REQUEST['file_id']);
17 if ($file != NULL)
18 {
19 header("Content-Type: {$file['type']}");
20 header("Content-Length: {$file['size']}");
21 if ($asattach)
22 header("Content-Disposition: attachment; filename={$file['name']}");
23 echo $file['contents'];
24 }
25 ob_end_flush();
26 }
27 catch (Exception $e)
28 {
29 ob_end_clean();
30 printException($e);
31 }
32 ?>