The following script is sitting in the root directory of my Website on Dreamhost’s server. When I first posted the script, it worked just fine, popping up a file dialog to allow the user to save MP3 files rather than automatically play them in the browser:
// Define the path to file
$file = $_GET[‘f’];
// File doesn’t exist, output error
// Set headers
header(“Content-Description: File Transfer”);
header(“Content-Disposition: attachment; filename=$file”);
// Read the file from disk readfile($file);
The PHP script is being called from within the HTML with the following tag (this code is in the index.html file):
What results is a browser page showing “http://www.djpetesavas.com/download.php?f=player/pause_again.mp3” in the address bar, and displaying only the text “player/pause_again.mp3” against a white background.
As I stated, when I first posted this script to my Website, it all worked perfectly. Then, about a month ago, the script started exhibiting the behavior it does currently.
If you’d like to try this yourself, go to www.djpetesavas.com and click on the download button (a blue circle with a down arrow in it) under the “Podcast” section on the main page.
Thanks in advance for all your help.