source: Base/Types/File/File.php

Last change on this file was 1, checked in by george, 15 years ago
  • Přidáno: Výchozí verze systému.
File size: 1.5 KB
Line 
1<?php
2
3class TypeFile
4{
5 function OnView($Item)
6 {
7 global $Database;
8
9 $DbResult = $Database->query('SELECT `Name`, `Size` FROM `SystemFile` WHERE `Id`='.$Item['Value']);
10 if($DbResult->num_rows > 0)
11 {
12 $DbRow = $DbResult->fetch_assoc();
13 return('<a href="types/File/FileDownload.php?Id='.$Item['Value'].'">'.$DbRow['Name'].'</a> ('.HumanSize($DbRow['Size']).')');
14 } else return('');
15 }
16
17 function OnEdit($Item)
18 {
19 // Check max value of upload_max_filesize
20 // ini_set("upload_max_filesize", "100M");
21 // <input type="hidden" name="MAX_FILE_SIZE" value="10000000">
22 $Output = '<input type="file" name="'.$Item['Name'].'" value="">';
23 return($Output);
24 }
25
26 function OnLoad($Item)
27 {
28 global $Database, $Config;
29
30 $Result = 0;
31 //print_r($_FILES);
32 if(array_key_exists($Item['Name'], $_FILES) and ($_FILES[$Item['Name']]['name'] != ''))
33 {
34 if(file_exists($_FILES[$Item['Name']]['tmp_name']))
35 {
36 $FileName = substr($_FILES[$Item['Name']]['name'], strrpos($_FILES[$Item['Name']]['name'], '/'));
37 $Database->query('INSERT INTO SystemFile (`Name`, `Size`) VALUES ("'.$FileName.'", '.filesize($_FILES[$Item['Name']]['tmp_name']).')');
38 $Result = $Database->insert_id;
39 if(!move_uploaded_file($_FILES[$Item['Name']]['tmp_name'], $Config['UploadFileFolder'].'/'.$Result)) SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!');
40 }
41 }
42 return($Result);
43 }
44}
45
46?>
Note: See TracBrowser for help on using the repository browser.