Using the following code:
Code: Select all
<?php
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="$file"');
readfile('music/'.$file);
?>In IE, I get a download box with the suggested filename equal to the whole URL:
You have chosen to download
test.php?file=file_to_be_downloaded
from servername
In Netscape, it gets the filename right but appends .php onto it:
You have chosen to download
file_to_be_downloaded.extension.php
from servername
In Opera and Mozilla however, it seems to work without a hitch. Are there any weird workarounds I should know about?
The files are held on a UNIX server running apache. They've all been chmodded so that only the script can read them, and the files can't be accessed directly.