Redirect after force download
Moderator: General Moderators
Redirect after force download
I have a force download, which uses headers obviously so I can't redirect with a header in the script. It pops the download up on the page, but I need the page to either refresh or redirect after download has started. Ive tried putting headers in the form for the download, tried in the force download in the code regardless, tried java and a header in the force download code, but am stuck. Any ideas?
Re: Redirect after force download
Sorry for this, im just kinda stuck here. Still have nothing working...
Re: Redirect after force download
Do the reverse. Have the confirmation page trigger the download. For example, suppose a visitor requests confirm.php.
confirm.php
The meta tag tells the visitor's browser to request download.php.
download.php
Because download.php specifies that it should be downloaded as an attachment, the visitor's browser stays on confirm.php while downloading the file.
confirm.php
Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>Confirmation</title>
<meta http-equiv="refresh" content="0;url=http://localhost/download.php" />
</head>
<body>
<p>Your download should have begun. If not, try <a href="http://localhost/download.php">download.php</a>.</p>
</body>
</html>download.php
Code: Select all
<?php
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename=example.txt');
echo 'Example';Re: Redirect after force download
mmm thanks! Can't believe that logic slipped my mind.