Changeset 25 for types/File
- Timestamp:
- Nov 20, 2008, 12:19:52 PM (16 years ago)
- Location:
- types/File
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
types/File/File.php
r22 r25 7 7 global $Database; 8 8 9 $DbResult = $Database->query('SELECT `Name`, LENGTH(`Content`)FROM `SystemFile` WHERE `Id`='.$Item['Value']);9 $DbResult = $Database->query('SELECT `Name`, `Size` FROM `SystemFile` WHERE `Id`='.$Item['Value']); 10 10 if($DbResult->num_rows > 0) 11 11 { 12 12 $DbRow = $DbResult->fetch_assoc(); 13 return('<a href="types/File/FileDownload.php?Id='.$Item['Value'].'">'.$DbRow['Name'].'</a> ('.HumanSize($DbRow[' LENGTH(`Content`)']).')');13 return('<a href="types/File/FileDownload.php?Id='.$Item['Value'].'">'.$DbRow['Name'].'</a> ('.HumanSize($DbRow['Size']).')'); 14 14 } else return(''); 15 15 } … … 26 26 function OnLoad($Item) 27 27 { 28 global $Database ;28 global $Database, $Config; 29 29 30 30 $Result = 0; … … 34 34 if(file_exists($_FILES[$Item['Name']]['tmp_name'])) 35 35 { 36 $Content = file_get_contents($_FILES[$Item['Name']]['tmp_name']);37 36 $FileName = substr($_FILES[$Item['Name']]['name'], strrpos($_FILES[$Item['Name']]['name'], '/')); 38 $Database->query('INSERT INTO SystemFile (`Name`, ` Content`) VALUES ("'.$FileName.'", 0x'.bin2hex($Content).')');37 $Database->query('INSERT INTO SystemFile (`Name`, `Size`) VALUES ("'.$FileName.'", '.filesize($_FILES[$Item['Name']]['tmp_name']).')'); 39 38 $Result = $Database->insert_id; 40 unlink($_FILES[$Item['Name']]['tmp_name']);39 if(!move_uploaded_file($_FILES[$Item['Name']]['tmp_name'], $Config['UploadFileFolder'].'/'.$Result)) SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!'); 41 40 } 42 41 } -
types/File/FileDownload.php
r21 r25 18 18 Header('Content-Type: '.DetectMimeType($DbRow['Name'])); 19 19 Header('Content-Disposition: attachment; filename="'.$DbRow['Name'].'"'); 20 echo( $DbRow['Content']);20 echo(file_get_contents($Config['UploadFileFolder'].'/'.$DbRow['Id'])); 21 21 } else echo('Soubor nenalezen!'); 22 22
Note:
See TracChangeset
for help on using the changeset viewer.