Page 1 of 1

redirect after headers sent

Posted: Fri Jun 02, 2006 9:34 am
by dstefani
Hello,

Can I do anything to redirect after spawning the download dialog?

I have a file that uses these headers and offers a download:

Code: Select all

function stream_rtf_file($file_name, $file_text) {

    include "includes/rtf_class.php";

    // headers
    Header("Content-type: application/octet-stream");
    Header("Content-Disposition: attachment; filename=$file_name");

    // do it
    $rtf = new RTF("includes/rtf_config.inc");
    $rtf->parce_HTML($file_text);
    $fin = $rtf->get_rtf();
    echo $fin;


}
If this was a pop-up window, that would be fine, but i don't want to use a pop-up, how can I go anywhere after I do this?

Thanks,

dstefani

Posted: Fri Jun 02, 2006 10:27 am
by Oren
You can't redirect after the output was sent - not with PHP.

Posted: Fri Jun 02, 2006 10:43 am
by RobertGonzalez
Use meta redirecting in your HTML. After a set time, it will refresh to another location.

Code: Select all

<html>
<head>
<meta http-equiv="refresh" content="5;url=http://www.mysite.com/index.php">
</head>
<body>
</body>
</html>
In this example, after 5 seconds, the page redirects to http://www.mysite.com/index.php.

Posted: Fri Jun 02, 2006 2:12 pm
by aerodromoi
Another option would be a JavaScript redirect using:

Code: Select all

window.location="http://www.targetdomain.com/";
However, I'd always include a text link to that page since you never
know whether the user has JavaScript enabled or not.

aerodromoi