Rodney Wormsbecher Rodney Wormsbecher - 1 year ago 154
PHP Question

laravel return pdf download but still want to redirect

I'd like to ask if anyone knows any way to redirect an user if a return has already been send.

In my case I try to accomplish the following. A pdf is generated and send by the browser as a download. But after it's being send I'd still like to redirect because the database records will be updated in the process.

my code in the controller is as below:

session::flash('informationmessage', 'The labour entries were billed');
return $pdf->download();

any help would be appreciated, cheers

Answer Source

No, you can't. For the redirection is done by client side, it's a small js code generate by server side. When the request is done, the connection is closed. Server side can not send info to browser any more. you may try open a new tab for download and you redirect the main tab.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download