How to create a download link for a PDF file?

Hi All,

I am a newbee. Forgive me if my question is very basic.

I have a pdf here in my root folder: /docs/CFCB-new-patient-form.pdf

I created this link on my view file

<div class="box_button fl download_link">

 <a href="../docs/CFCB-new-patient-form.pdf">Download Application</a> 


But If I click the link Download Application the page is redirected to


where I see my home page.

How can I create this link works? I just want to download the file if the above link is clicked.


try this:

use yii\helpers\Html;

<div><?= Html::a('Download Application', '../docs/CFCB-new-patient-form.pdf', ['target' => '_blank', 'class' => 'box_button fl download_link']) ?></div>

1 Like