Reputation: 952
I am using a script to create PDF files. After creating the PDF file I want to redirect the user to anonther page.
When I run the script I only get the PDF file. The script is not redirecting me to another page.
Does someone know how I can redirect users to another page?
Here is my script:
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=test.pdf");
readfile('./temp/pdf/test.pdf');
header("Location: http://www.example.com");
die();
I have also tried to redirect with the meta refresh tag
but the script is still not redirecting:
<meta http-equiv="refresh" content="1;url=http://www.example.com">
Upvotes: 0
Views: 372
Reputation: 155648
After creating the PDF file I want to redirect the user to anonther page.
This is not possible with HTTP.
Instead, you should create the file, redirect the user, and then the web-page target of the redirection serves up the PDF response through a JavaScript redirection (PDFs generally cannot run JavaScript that interacts with the browser)
Upvotes: 1