Hi there, quick question: I've got a form that forces a user to enter an email, after which a download/attachment is pushed and a file is downloaded... the file downloads fine... however...
My problem is that when the download starts, the page locks up, and the user can't navigate anywhere or do anything on the page until the file is downloaded (ie: clicking the "go home" link below). Any better solutions than what I come up with here? I know i'm probably missing something really simple ... this is my first crack at setting up a private download page.
<script type="text/javascript">
function redirect_function(loc){
window.location = loc;
}
</script>
<?php
// after form is submitted
$condition_met=check($_POST['email']);
if($condition_met) { ?>
<p>Your file will begin downloading in 5 seconds.</p> <a>go home</a>
<script type="text/javascript">
setTimeout('redirect_function("download.php")', 5000);
</script>
<?php } ?>
The called (download.php) page looks like this, this is where it hangs up the page...
<?php
ob_start();
if($some_condition) { // check for authorization, etc
$file='location/file.ext';
header('Content-type: application/force-download');
header('Content-disposition: attachment; filename="'. basename($file) .'"');
header('Content-length: '. filesize($file) );
readfile( $file );
} else {
echo "error message";
}
ob_end_flush();
?>