Quantcast
Channel: Anil Konsal
Viewing all articles
Browse latest Browse all 10

Bye Bye ugly Content Disposition Attachment with Yii

$
0
0

Hi,

With Yii Framework, you can say good bye to ugly header code for forcing download a file on client side (I usually used for pdf files download forcibly) so that client browser should not try to open in in-built file handler.

1
2
$request = Yii::app()->getRequest();
$request->sendFile('abc.pdf', file_get_contents(Yii::app()->basePath.'/files/mypdf'))

As Per Yii Docs, this function takes care of all the headers required to accomplish the task. So all clean work now.


Viewing all articles
Browse latest Browse all 10

Trending Articles