Esempio n. 1
0
 public function transmit_file($id, $size = '', $disposition = 'attachment')
 {
     $item = $this->one($id);
     #validation
     if (!count($item)) {
         throw new ApplicationException('No file specified');
     }
     if ($item['status'] != 0) {
         throw new ApplicationException('Access Denied');
     }
     $size = UploadUtils::check_size($size);
     $filepath = $this->get_upload_path($id, $item['ext'], $size);
     $filename = str_replace('"', "'", $item['iname']);
     #quote filename
     header('Content-type: ' . UploadUtils::get_mime4ext($item['ext']));
     header("Content-Length: " . filesize($filepath));
     header('Content-Disposition: ' . $disposition . '; filename="' . $filename . '"');
     #logger('transmit file '.$filepath." $id, $size, $disposition, ".UploadUtils::get_mime4ext($item['ext']));
     $fp = fopen($filepath, 'rb');
     fpassthru($fp);
 }