Reputation: 311
When i call this function first time then file downloaded but after refresh the page it show me some not understanding character on my browser screen
// Controller Code
public function actionDownload($id)
{
$model = $this->findModel($id);
$file ='../frontend/uploads/users/'.$model->image;
if(file_exists($file))
{
return Yii::$app->response->sendFile($file);
exit;
}
//Button Code
[
'attribute'=>'resume',
'label'=>'Resume',
'format'=>'raw',
'value'=>function($data)
{
if($data->resume != null)
{
// $url = Yii::$app->params['application_base'].'admin/user/download/'.$data->id;
return Html::a('Download', ['download','id'=> $data->id]);
}
else
{
return 'NA';
}
},
],
Upvotes: 1
Views: 1074
Reputation: 56
Try to omit a pjax
amd use
return Html::a('Download', ['download','id'=> $data->id, 'data-pjax' => 0]);
instead of
return Html::a('Download', ['download','id'=> $data->id]);
Upvotes: 1