source: trunk/types/File/FileDownload.php

Last change on this file was 25, checked in by george, 16 years ago
  • Upraveno: Data přijatých souborů neukládat přímo do databáze, ale ponechat je na disku.
File size: 723 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!');
22
23?>
Note: See TracBrowser for help on using the repository browser.