Adrianna
(Rhea Uplb)
1
Can somebody teach me how to set the file name as a link to view/download that file? I have read many posts about this but it doesn’t work for me.
This is my view preview.
5545
![Screenshot from 2014-05-09 10:13:07.png](https://www.forum.yiiframework.com/ipb_uploads/monthly_05_2014/post-224295-032289800%201399601818.png)
What i want is that Purchase Document to be a link.
This is my view code:
<b><?php echo CHtml::encode($data->getAttributeLabel('purchase_document')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($model->purchase_document), Yii::app()->baseUrl . '/files/pr/' . $model->purchase_document); ?>
<br />
I would really appreciate your help. Thank you.
paalgg
(Paalgg)
2
You can set filename for download by adding this header line:
header('Content-Disposition: attachment; filename="downloaded.pdf"');
Example copied from http://www.php.net/m...tion.header.php
Try this code.
CHtml::link("Download FILE", "http://" . $_SERVER["SERVER_NAME"] . Yii::app()->request->baseUrl . "/files/pr/" . $model->purchase_document)',