What I read here is it is not possible or not ideal to download then redirect to another page. I use this hook gform_after_submission
to trigger php script download after user submitted the form. But after the download started the page doesn't redirect to another text/page/url just like what documentation does here. I guess that is because of the header
function. So what could be the best way to achieve this? I have few options but there are few things that I need some answers:
- Use javascript to manually redirect after download started - but it seems i cant find a way to get the text/page/url that is set in the gravity form so I can use it in the javascript. Is there anyway to get it?
- Start the download script when it is already directed to other page. - but how do I do that? Cant find any hooks that will tell me if Im already redirected to another page after submission.
Here is my download script:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($final_file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($final_file));