Page 1 of 1

Download script displays wrong filename

Posted: Sun Dec 07, 2003 10:14 pm
by Ianm
I am using this download script (audio.php) to get files from a protected folder. I am fairly new to php so I do not know how to expand on this to get it right. What it is doing is downloading the mp3 files as audio.mp3 even though the filename is different. How can I get it to download the right filename? Thanks.

This is the audio.php

Code: Select all

<?php
$path="./media/"; // Path to protected directory 
$mimetype="audio/mp3"; // Mime type of file 
Header("Content-Type: $mimetype");  
readfile ($path . $id);
?>
and the file that links to it, uses the url http://www.example.com/media.php?id=song.mp3

Thanks again.

Posted: Mon Dec 08, 2003 12:04 am
by m3mn0n
The [php_man]header[/php_man]() page in the manual has some information that you might be interested in.