We help IT Professionals succeed at work.

header('Content-Disposition: attachment; filename="jaycee.m3u"');

Jaycee asked

I have a tiny problem.

I am generating a m3u file, that I want IE to open it, without having IE ask me to open or download it. (Always Ask .. option is grayed out).
Here is the files:

header("Content-type: audio/x-mpegurl"); // tested without "x-" as well.
header('Content-Disposition: attachment; filename="jaycee.m3u"');
echo "#EXTM3U\n";

jaycee.m3u (generated):

If I download the generated file, put it on the web server, and try to download it directly, the option is available, and I am able to listen the file without having to confirm the opening.

So, I beleive that IE doesn't like opening a php, and having the server returning otherwise. (May I wrong?)

Does anyone have an idea to deal with this ?
(otherwise that add m3u file as php extension and rename my stream.php in stream.m3u)

Thanx for your help.

Watch Question

Top Expert 2006
well, you could offcourse try url below and try to trick msIE as commonly done by php generated images:


Top Expert 2007

Have you compared the headers send by the webserver when using the .mu3-file directly or when using the stream.php ? try it with a network sniffer on your client  so you might see whats different.


Roonaan : Doesn't work ... (just tried.. ) but thanx for your reply...

Hernst42: I just tested with fiddler. the only major difference is the content-disposition in the header...  (and a X-Powered by php, but I beleive this is not relevant ... ).

I tryed removing the content-dispo, the phpfile is opened correclty, but this is not the behaviour I need ...

Hum, it seems that according to this: http://support.microsoft.com/kb/q182315/
it would be impossible ...

any trick ? or should I stop php and become a plumber ?

hernst42, btw, thank you for your reply too .. :)
Top Expert 2007
You might extend what Roonaan suggested a little bit more like this:

It should still execute the php-script but most browsers get the real name of the script correctly.

The link you posted from mysql only states that for IE 4.x, but whos usingsuch an old browser.

Can you post that headers from the file and php-download if the advice above does not work?

I was confronted with that problem and I believe adding the content-length did the trick ... not sure though, try it out and let us know :

$data = "#EXTM3U\n";
header("Content-type: audio/x-mpegurl"); // tested without "x-" as well.
header ( 'Content-Length: ' . strlen ( $data ) );
header('Content-Disposition: attachment; filename="jaycee.m3u"');
echo $data;


You could use HTACCESS to call it a m3u file.

create a htaccss file:

have this:

ReWriteEngine On
ReWriteRule stream.m3u stream.php

then the file:
stream.php will be loaded when someone loads stream.m3u...



I found the problem (which is, obviously not a problem, but a feature)...
according to http://http://www.nic.mil/ftp/rfc/rfc2183.txt a browser MUST ask the user to open or download a file if a ( content-disposition : attachement ) header is provided.

I will split the points since you all tried to find a solution .

Thank you for your support.