On 10/12/2010 1:58 p.m., Nick Taylor wrote:
> When I run this
> <?php
> 
> $file='directory/test.mp3';
> 
> header("Content-Type: mp3");
> header('Content-disposition: attachment; filename="'.$file.'"');
> 
> ?>
> it tries to access
> 
> directory_test.mp3

The filename in the content-disposition header isn't the name of a file
on your server - it's informing the user's browser what name to give the
file you're downloading to them. This gets used in the saved ialog.
It's up to you to actually send some file content after these headers,
as just setting a filename in the content-disposition won't actually
send any content.

Try something like

 $file = 'test.mp3';
 header("Content-Type: audio/mp3");
 header('Content-disposition: attachment; filename="'.$file.'"');
 readfile('directory/test.mp3');

-- 
TIM OLIVER
Software Engineer

158 Leinster Road, Merivale, PO Box 36578
Christchurch 8146, New Zealand

P  +64 3 377 0007   F  +64 3 353 1308   E  [email protected]

E2DIGITAL.CO.NZ

-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to