dcatadmin 自定义文件导出功能文件下载输出问题
场景:dcatadmin 自定义文件导出功能(求教)
之前导出功能有写好的方法,切换dcat后就参考(https://learnku.com/docs/dcat-admin/2.x/toolbar/8093#244e3c) 自定义了导出按钮,
但是在 自定义文件的 handle 方法中调用文件下载方法,返回结果就一直如下图所示
试过 以下几种方法,都是一样的结果。
1、return Storage::disk('local')->download('temp_file/'.$result['data']['file_name']);
2、 return response()->file(storage_path().'/app/temp_file/'.$filename,$headers);
3、 return response()->streamDownload(function () use($filename) {
echo file_get_contents(storage_path().'/app/temp_file/'.$filename);
}, $filename);
4、以及原生php下载代码
// 设置下载文件内容格式
header('Content-type: application/octet-stream');
// 设置下载文件名
header('Content-Disposition: attachment; filename="laravel.zip"');
// 读取二进制文件流返回给客户端浏览器
$filepath = storage_path().'/app/temp_file/问题.zip';
// echo $filepath;
// die();
readfile($filepath);
请各位大神指点。
handle里面有个response->success()->download