Below are codes for controller and view respectively
## Controller
` public function actionDownload($id) {
$download = Status::findOne($id);
$path = Yii::getAlias('@webroot') . '/uploads/status/' . $download->image_web_filename;
if (file_exists($path)) {
return (Yii::$app->response->SendFile($path, $download->image_web_filename)->send());
exit;
} else {
throw new NotFoundHttpException("can't find {$download->image_web_filename} file");
}
}`
## View
%PDF-1.4 %�쏢 5 0 obj <> stream x��]K�%ECű%P4���y��.�u�@�Q �zt��P�0��_��'��gx����/3�n���zܞ���xaAR7o�s�<�;�����܈�o��w?8��]�y�/'�O�FU��@b㍤���G����͇'r����4�+B��{3���SW����'��<�������A�ǃ*x���N27r�$���V������w�_?��k�~���+�'wFr6��f! ��ȍ7�Ӡ���UG���g;=�2�j��Ǒ �oƱQƇfh�?�WҘ�0۟��/�l�E���i(�{��* ��'�W��8��T�j 2��p������\��aܵH�$�Ci��u��$j��QZ���aIk����\o���D2Y)�/FV��nġ�a����� �_ؐ��rf�� �7�*� �IN�J{�l����Cqr�D�������[�]9���E�7�����k�j���9N�\�EC��F����&ռ-����uJV����3����L!�f��x���F�����̈́��#��U����:*g��&C�ӤD��q�17�@Jg+�J����w��ߨ?M_�a���R�ݼ��zu%��\�#�7$M&���-dO"#�]�i�89�}��<��� m��04�I�bHJ �O�M��f�Ϯ�E�{2}`���n�����.l���+cZ?�����6C��N��XZJW�ylȒ��"�D�ͧ�8s���q��om��ݍx�6(��T�9Uɨ�g���x���\���'�Ͻ����BE��|���
Thank you for your question.
In order for this issue tracker to be effective, it should only contain bug reports and feature requests.
We advise you to use our community driven resources:
If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.
_This is an automated comment, triggered by adding the label question._
I had the exact problem, It turned out that my link to download action was placed inside the Pjax::begin() Pjax::end() methods, so the content of the file was treated as update for the page.
My solution: add data-pjax="0" attribute to download link in your view file.
verry
I had the exact problem, It turned out that my link to download action was placed inside the Pjax::begin() Pjax::end() methods, so the content of the file was treated as update for the page.
My solution: add data-pjax="0" attribute to download link in your view file.
Great. Solved my problem!
Most helpful comment
I had the exact problem, It turned out that my link to download action was placed inside the Pjax::begin() Pjax::end() methods, so the content of the file was treated as update for the page.
My solution: add data-pjax="0" attribute to download link in your view file.