Ignore:
Timestamp:
Apr 1, 2013, 10:17:42 AM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Aktuality přepracovány na aplikační modul.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/File/File.php

    r505 r506  
    1313  function Delete($Id)
    1414  {
    15     global $Config;
    16    
    1715    $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id);
    1816    if($DbResult->num_rows > 0)
     
    2624  function CreateFromUpload($Name)
    2725  {
    28     global $Config;
    29    
    3026    // Submited form with file input have to be enctype="multipart/form-data"
    3127    $Result = 0;
     
    3733        $this->Database->query('INSERT INTO File (`Name`, `Size`) VALUES ("'.$FileName.'", '.filesize($_FILES[$Name]['tmp_name']).')');
    3834        $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;
    4036      }
    4137    }
     
    5450  function Download($Id)
    5551  {
    56     global $Config;
    57    
    5852    $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id));
    5953    if($DbResult->num_rows > 0)
    6054    {
    6155      $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!');
    6662    } else echo('Soubor nenalezen!');
    6763  }
Note: See TracChangeset for help on using the changeset viewer.