download csv files from uploaded in directory

i have folder in my web folder i have csv file inside that,i need when user click on download link it will download,below is my code i m using

in view




<?= Html::a( '  Download Sample file here', ['/student/download'], ['class'=>'pull-left']) ?>



in controller




public function actionDownload()

    {    

         $pa= Yii::$app->getBasePath();

         $f='student.csv';

        

        Yii::$app->response->xSendFile( $pa.'/web/csv-samples/student.csv' ); 

    }



my problem is when i click on download link pop-up is opnening and i can download file but problem is file is coming emprty,or if i m using image then image also coming empty(0 byte).

please i need help on this.

Hi!

I would guess your webserver is not supportding xSendFile.

Read: http://www.yiiframework.com/doc-2.0/yii-web-response.html#xSendFile()-detail

Regards