Download script displays wrong filename

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ianm
Forum Newbie
Posts: 1
Joined: Sun Dec 07, 2003 10:14 pm

Download script displays wrong filename

Post 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.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

The [php_man]header[/php_man]() page in the manual has some information that you might be interested in.
Post Reply