H
H
hollanditkzn2017-03-29 17:31:25
Yii
hollanditkzn, 2017-03-29 17:31:25

How to download a file to a computer when clicking on a link?

I have a question, the file itself opens in the browser, but I need it to be immediately downloaded to the computer when clicking on the link, in my case on the icon
In the controller

public function actionView($id)
    {

        return $this->render('view', [
            'model' => $this->findModel($id),
            'user_name' => $user_name,
        ]);
    }

in view
<?= DetailView::widget([
        'model' => $model,
        'attributes' => [
[
                'attribute' => 'img',
                'format' => 'raw',
                'value' => Html::a('<span class="glyphicon glyphicon-paperclip"></span>', '@web/'.$model->img)
            ],
]

I get the path crm/frontend/web//attachment/name.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
padlyuck, 2017-03-29
@hollanditkzn

stackoverflow.com/questions/2408146/href-image-lin...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question