Changeset 506 for trunk/Modules/File/File.php
- Timestamp:
- Apr 1, 2013, 10:17:42 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/File/File.php
r505 r506 13 13 function Delete($Id) 14 14 { 15 global $Config;16 17 15 $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id); 18 16 if($DbResult->num_rows > 0) … … 26 24 function CreateFromUpload($Name) 27 25 { 28 global $Config;29 30 26 // Submited form with file input have to be enctype="multipart/form-data" 31 27 $Result = 0; … … 37 33 $this->Database->query('INSERT INTO File (`Name`, `Size`) VALUES ("'.$FileName.'", '.filesize($_FILES[$Name]['tmp_name']).')'); 38 34 $InsertId = $this->Database->insert_id; 39 if(move_uploaded_file($_FILES[$Name]['tmp_name'], $ Config['Web']['UploadFileFolder'].'/'.$InsertId.'_'.$FileName)) $Result = $InsertId;35 if(move_uploaded_file($_FILES[$Name]['tmp_name'], $this->FilesDir.'/'.$InsertId.'_'.$FileName)) $Result = $InsertId; 40 36 } 41 37 } … … 54 50 function Download($Id) 55 51 { 56 global $Config;57 58 52 $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id)); 59 53 if($DbResult->num_rows > 0) 60 54 { 61 55 $DbRow = $DbResult->fetch_assoc(); 62 //Header('Content-Type: '.$this->DetectMimeType($this->FilesDir.'/'.$DbRow['Name'])); 63 //Header('Content-Disposition: attachment; filename="'.$DbRow['Name'].'"'); 64 print_r($this); 65 echo(file_get_contents($this->FilesDir.'/'.$DbRow['Name'])); 56 if(file_exists($this->FilesDir.'/'.$DbRow['Name'])) 57 { 58 Header('Content-Type: '.$this->DetectMimeType($this->FilesDir.'/'.$DbRow['Name'])); 59 Header('Content-Disposition: attachment; filename="'.$DbRow['Name'].'"'); 60 echo(file_get_contents($this->FilesDir.'/'.$DbRow['Name'])); 61 } else echo('Soubor nenalezen!'); 66 62 } else echo('Soubor nenalezen!'); 67 63 }
Note:
See TracChangeset
for help on using the changeset viewer.