I have a script for wav files download:
down.php:
<?php
if (isset($_GET['file'])) {
$file = $_GET['file'] ;
if (file_exists($file) && is_readable($file) && preg_match('/\.wav$/',$file)) {
$fileName = basename($file);
header('Content-type: application/wav');
header("Content-Disposition: attachment; filename=".$fileName);
readfile($file);
}
} else {
header("HTTP/1.0 404 Not Found");
echo "<h1>Error 404: File Not Found: <br /><em>$file</em></h1>";
}
?>
so when I click on my hyperlink in myPage.php:
<a href=<?php echo "down.php?file=full_file_path"?>><?php echo "file_name"?></a>
a file gets downloaded!
How can I reload myPage.php after download dialog box gets closed, that is when a file gets downloaded?
I've tried few things but none of it worked. Like, redirection after readfile(), then I found out that it's impossible to output the header after you have output the file. Calling javascript function on onclick event to reload location. Opening down.php?file=full_file_path
first and then reloading location. and more ...
Any idea where and how to do it?