PHP
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists PHP

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old June 12th, 2008, 06:31 AM
Aschwin Wesselius
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Redirect after pdf / file download

Yashesh Bhatia wrote:
Hello:
>

I'm trying to emulate a problem i'm trying to solve as follows.
>

1 - user enters information into a html form and submits
2 - a php script is invoked on the submit and a pdf file is stamped
and made available for download
3 - the script finally redirects the user to a thank you html page.
>

i'm having a problem in the redirect to the thank you page.
here's the 3 files
1.html
<html><body>
<form action="2.php" method="post">
First Name: <input type="text" name="firstname" />
Last Name: <input type="text" name="lastname" />
<input type="submit" />
</form>
</body></html>

2.php
<?php
// some stamping code
// open the file in a binary mode
$name = "2.pdf";
fp = fopen($name, 'rb');
>

// send headers, dump the pdf file and finally redirect
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=$name");
header("Content-Length: " . filesize($name));
fpassthru($fp);
>

echo '<script type="text/javascript">';
echo 'window.location.href="3.html";';
echo '</script>';
?>

3.html
<html><body>
Thank you for downloading 2.pdf
</body></html>

>

The submit works fine and the pdf is availble for download however,
the redirect does not happen.
If i comment the lines
//header("Content-Type: application/pdf");
//header("Content-Disposition: attachment; filename=$name");
//header("Content-Length: " . filesize($name));
//fpassthru($fp);
>

then the redirect happens after the submit.
>

i'm testing / running it on fedora core 6, Apache 2.2.5, php 5.2.5 and
firefox 1.5
Any help / pointers is appreciated.
>

Thanks.
>

Yashesh Bhatia.


Hi,

What you are doing is:

header("Content-Type: application/pdf");


And after that you try to echo some script. But the browser already
thinks that belongs to the PDF and not to a HTML page.

What I think should work instead of the script part is just:

header('Location: 3.html');
exit;

But I'm not sure it works.

--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists PHP > Redirect after pdf / file download


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway