Skip to content

Instantly share code, notes, and snippets.

@zmiftah
Last active January 2, 2016 18:49
Show Gist options
  • Save zmiftah/8346607 to your computer and use it in GitHub Desktop.
Save zmiftah/8346607 to your computer and use it in GitHub Desktop.
<?php
class LaporanController extends CController
{
public function actionDownload()
{
$filename = $_GET['name'];
$reportPath = Yii::app()->basePath.'/report/';
if (file_exists($reportPath.$filename)) {
Yii::app()->getRequest()->sendFile( $name , file_get_contents( $reportPath.$name ) );
} else {
throw new CHttpException(404, 'The requested file does not exist.');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment