当我第一次调用此函数然后文件已下载但刷新页面后,它显示我的浏览器屏幕上有一些不理解的字符
// 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';
}
},
],
答案 0 :(得分:1)
尝试省略pjax
amd use
return Html::a('Download', ['download','id'=> $data->id, 'data-pjax' => 0]);
而不是
return Html::a('Download', ['download','id'=> $data->id]);