source: trunk/www/Base/Types/File/FileDownload.php

Last change on this file was 93, checked in by chronos, 11 years ago
  • Fixed: System variable as parameter to constructors of descendents of Module class.
  • Removed: End PHP mark "?>" from all files.
File size: 720 bytes
Line 
1<?php
2
3// For proper mime-type detection php-pecl-Fileinfo package should be installed on *nix systems
4function DetectMimeType($FileName)
5{
6 $FileInfo = new finfo(FILEINFO_MIME, '/usr/share/misc/magic');
7 $Result = $FileInfo->file($FileName);
8 //$FileInfo->close();
9 return($Result);
10}
11
12chdir('../..');
13include('global.php');
14$DbResult = $Database->select('SystemFile', '*', 'Id='.addslashes($_GET['Id']));
15if($DbResult->num_rows > 0)
16{
17 $DbRow = $DbResult->fetch_assoc();
18 Header('Content-Type: '.DetectMimeType($DbRow['Name']));
19 Header('Content-Disposition: attachment; filename="'.$DbRow['Name'].'"');
20 echo(file_get_contents($Config['UploadFileFolder'].'/'.$DbRow['Id']));
21} else echo('Soubor nenalezen!');
Note: See TracBrowser for help on using the repository browser.