Reputation: 87
I need a file to download when a form is submitted, however I also want to have the page redirect back to the form with a "form submitted" message.
Obviously something like this wont work:
return Redirect::to('form')->with('sent', true);
$downloadLink = base_path().'/something.pdf';
return Response::download($downloadLink);
Is there a way to do this?
Thanks!
Upvotes: 0
Views: 885
Reputation: 1386
Try this
$data = array('sent' => true, 'downloadlink' => $downloadlink);
return Redirect::to('form')->with('data', $data);
if JSON:
return Response::json(['sent' => true, 'data' => $data']);
to access data in view:
var_dump($data['sent']), var_dump($data['downloadlink'])
Upvotes: 1