Redirect to file
Posted: Thu Mar 25, 2004 11:14 pm
Hi,
I've got a page where a user has to input a code on a form to download a midi file. The form input is sent to a download.php page where if the code is correct the page should redirect to the file.
I've managed to use the header(location: ) idea but the problem is that the midi file opens in the browser when I need the download dialog to appear.
I've used
too but this caused the file to be saved as a .php and also revealed the url to the file (unless I used the code incorrectly) because it offered the url incase the browser had made a mistake not knowing how to handle the file (netscape).
The redirect function needs to be placed inside a switch in an if command since there are many different files the page can redirect to.
Any idea how to make my redirect work so that the download dialog apppears?
I've got a page where a user has to input a code on a form to download a midi file. The form input is sent to a download.php page where if the code is correct the page should redirect to the file.
I've managed to use the header(location: ) idea but the problem is that the midi file opens in the browser when I need the download dialog to appear.
I've used
Code: Select all
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=filename.ext");The redirect function needs to be placed inside a switch in an if command since there are many different files the page can redirect to.
Any idea how to make my redirect work so that the download dialog apppears?