コード例 #1
0
 /**
  * get full information for an upload
  *
  * @param string $file 
  * @param array $file_data 
  * @return array
  * @author Andy Bennett
  */
 function get_upload_data($file, $file_data)
 {
     $filename = self::save($file);
     if (APPENV == 'frontend') {
         $upl_dir = str_replace('frontend', 'backend', Kohana::config('upload.directory'));
         if (!copy($filename, $upl_dir . basename($filename))) {
             Kohana::log('error', "COPY FAILED: copy({$filename}, {$upl_dir}.basename({$filename}))");
         }
     }
     $pp = pathinfo($filename);
     $ext = $pp['extension'];
     $file_type = self::check_filetype($file_data['type'], $filename);
     $d = Kohana::config('upload.directory');
     $upload_data['file_name'] = $pp['basename'];
     $upload_data['file_type'] = $file_type;
     $upload_data['file_path'] = $d;
     $upload_data['full_path'] = $filename;
     $upload_data['raw_name'] = $pp['filename'];
     $upload_data['orig_name'] = $file_data['name'];
     $upload_data['file_ext'] = '.' . strtolower($ext);
     $upload_data['file_size'] = $file_data['size'];
     $upload_data['is_image'] = file::is_image($file_type);
     $upload_data['date_added'] = date('Y-m-d H:i:s');
     if ($upload_data['is_image']) {
         $properties = file::get_image_properties($filename);
         if (!empty($properties)) {
             $upload_data = array_merge($upload_data, $properties);
         }
     }
     return $upload_data;
 }
コード例 #2
0
 /**
  * get full information for an upload
  *
  * @param string $file 
  * @param array $file_data 
  * @return array
  * @author Andy Bennett
  */
 function get_upload_data($file, $file_data, $save = true)
 {
     $filename = $save ? upload::save($file_data) : $file;
     if (!strlen($filename)) {
         throw new Exception("Empty filename", 1);
     }
     $pp = pathinfo($filename);
     $ext = strtolower($pp['extension']);
     $file_type = uploads::check_filetype($file_data['type'], $filename, $ext);
     $d = Kohana::config('upload.directory');
     $upload_data['file_name'] = $pp['basename'];
     $upload_data['file_type'] = $file_type;
     $upload_data['file_path'] = $d;
     $upload_data['full_path'] = $filename;
     $upload_data['raw_name'] = $pp['filename'];
     $upload_data['orig_name'] = $file_data['name'];
     $upload_data['file_ext'] = '.' . strtolower($ext);
     $upload_data['file_size'] = $file_data['size'];
     $upload_data['is_image'] = file::is_image($file_type);
     $upload_data['is_video'] = 0;
     $upload_data['is_audio'] = 0;
     $upload_data['date_added'] = date('Y-m-d H:i:s');
     $upload_data['preview'] = false;
     $driver = uploads::get_driver($upload_data['is_image'], $file_type, $ext);
     if ($driver !== false) {
         // Load the driver
         if (Kohana::auto_load($driver)) {
             // Initialize the driver
             $upload_driver = new $driver();
             // Validate the driver
             if (!$upload_driver instanceof Uploader_Driver) {
                 throw new Kohana_Exception('core.driver_implements', $driver, 'upload', 'Uploader_Driver');
             }
             $upload_driver->generate_preview($upload_data, $filename, $ext);
         }
     }
     if ($upload_data['is_image']) {
         $properties = file::get_image_properties($filename);
         if (!empty($properties)) {
             $upload_data = array_merge($upload_data, $properties);
         }
     }
     return $upload_data;
 }
コード例 #3
0
 /**
  * undocumented function
  *
  * @param string $path 
  * @return void
  * @author Andy Bennett
  */
 protected function render($path, $download = false, $orig_name = null)
 {
     Kohana::close_buffers(false);
     if (is_null($orig_name)) {
         $orig_name = basename($path);
     }
     $file_type = uploads::check_filetype(file::mime($path), $path);
     header('Content-type: ' . $file_type);
     if (!file::is_image($file_type) or $download) {
         header('Content-Disposition: attachment; filename="' . $orig_name . '"');
     }
     header("Content-Length: " . filesize($path));
     readfile($path);
     exit;
 }
コード例 #4
0
 /**
  * undocumented function
  *
  * @param string $path 
  * @return void
  * @author Andy Bennett
  */
 protected function render($path, $download = false, $orig_name = null)
 {
     Kohana::close_buffers(false);
     if (is_null($orig_name)) {
         $orig_name = basename($path);
     }
     $file_type = mimes::check($path);
     header('Content-type: ' . $file_type);
     if (!file::is_image($file_type) and strpos($file_type, 'flash') === false or $download) {
         header('Content-Disposition: attachment; filename="' . $orig_name . '"');
     }
     header("Content-Length: " . filesize($path));
     readfile($path);
     if ($this->delete_fullpath) {
         unlink($this->delete_fullpath);
     }
     exit;
 }