Why I can't download a pdf file correctly in yii1.1?


Hi,guys! I am useing yii1.1, I want to implement a file upload and down load function, but after I upload my pdf file, I could’t download this file correctely. could you tell my why?

When I tried to download the file that I uploaded, I got an incomplete pdf file. In other words, I can’t open the pdf file that I downloaded.

public function actionDownload(){
    $path = Yii::getPathOfAlias('/yiiroot/trackstar/protected/uploads/')."mypdffile.pdf";

    $upload=new Upload();



public function downloadFile($fullpath){


        header("Content-type:application/pdf"); //for pdf file
        //header('Content-Type:text/plain; charset=ISO-8859-15');
        //if you want to read text file using text/plain header

        header('Content-Disposition: attachment; filename="'.basename($fullpath).'"');

        header('Content-Length: ' . filesize($fullpath));

    else {return false;}


I want to download my pdf file correctly.