无法完成。问题是,如果您向用户浏览器发送下载指令,则实际上是在发送响应,并且只能发送回一个响应。
您可以做的是,首先将您的用户重定向到“最终”页面,然后在该页面中开始下载。该代码将类似于:
Session::flash('download.in.the.next.request', 'filetodownload.pdf');return Redirect::to('/whatever/page');然后在新页面中,您将有一些选择:
- HTML:[meta http-equiv =“ refresh” content =“ 5; url = http://watever.com/create_csv.php ”]
- Javascript:location.href =’ http : //watever.com/create_csv.php ‘;
- iframe:[iframe src =“ create_csv.php”] [/ iframe]
因此,您可以在布局中执行以下操作:
<html> <head> @if(Session::has('download.in.the.next.request')) <meta http-equiv="refresh" content="5;url={{ Session::get('download.in.the.next.request') }}"> @endif <head> <body> ... </body></html>


