Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : ProtectedFile | ||
리턴 | ProtectedFile | the static model class |
public function actionGetImage($id) { if (!($file = \MediaData::model()->findByPk($id))) { throw new CHttpException(404, 'File not found'); } $filepath = $file->getPath(); if (!file_exists($file->getPath())) { throw new CException('File not found on filesystem: ' . $file->getPath()); } //var_dump($file); //die; header('Content-Type: ' . \MediaType::model()->findByPk($file->media_type_id)->type_mime); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Content-Length: ' . $file->original_file_size); ob_clean(); flush(); readfile($filepath); }