Re: Headers, downloads and redirection
From: Fabian Hore (fabianhore_at_email.com)
Date: 11/08/04
- Next message: Goroka: "Re: Course"
- Previous message: Mark C: "Re: Memory allocation question with NuSOAP and XML parsing"
- In reply to: Ilija Studen: "Re: Headers, downloads and redirection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 08 Nov 2004 01:08:32 GMT
Hi.
> > I have a script which validates a user's email, password and IP for
> > the purposes of a file download. The validation and error messages
> > work perfectly. After the validation and download, I want to redirect
> > the user to a thank you page.
I don't see how you can send a document and a redirect in the same stream.
If you send a document with a Location header the browser should ignore the
body
of that document and instead send another request for the specified
location.
If this works on some browsers, or on some sites, then I'd take that as a
fluke not to
be relied upon.
I guess the method could succeed if the body of the original document is
received
quickly enough before the subsequent one starts to download.
Best to steer clear of anything that goes against the way the protocol is
supposed to behave.
I just ran a quick test;
<?php
header("Content-Disposition: attachment; filename=doc.doc");
header("Content-Type: application/octet-stream");
header("Location: ./thanks.php");
echo readfile('./doc.doc');
?>
I never get the document.. just the thanks page. This is what I'd expect.
You say you get the download but not the redirect, which is odd!
I'd put it down to browser nuances and use a more reliable method.
I would suggest sending back the thanks page first which provides a link
and/or Javascript
invocation of the download. This will of course mean maintaining the state
of validation on
the server between requests.
"Ilija Studen" <remove_this_ilija.studen@gmail.com> wrote in message
news:2v79trF2jnlreU1@uni-berlin.de...
> Tyrone Slothrop wrote:
> > I have a script which validates a user's email, password and IP for
> > the purposes of a file download. The validation and error messages
> > work perfectly. After the validation and download, I want to redirect
> > the user to a thank you page. I have done this on other sites with no
> > problems, but this one seems to have a difference that is making me
> > crazy.
> >
> > The download works fine with the usual cache headers and force
> > download, readfile etc. However, the script refuses to redirect. I
> > have tried header ("location: ...") and an abbreviated echo of an HTML
> > redirect and neither works. Thought maybe it was a cache problem, so
> > I tried ob_start and ob_flush (worked great for the redirect, but the
> > file would not download).
> >
> > Anyone have any ideas?
> >
> > TIA!
>
> Try to print:
>
> <head>
> <script language="JavaScript">
> <!--
> window.location="http://someplace.com";
> //-->
> </script>
> </head>
>
> If server wonnt redirect, you can hope that browser will.
- Next message: Goroka: "Re: Course"
- Previous message: Mark C: "Re: Memory allocation question with NuSOAP and XML parsing"
- In reply to: Ilija Studen: "Re: Headers, downloads and redirection"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|