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
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)',