getURL and mp3

I have always used getURL(“whatever.mp3”, “_blank”) to allow a user to play an external mp3 on his/her own systems player (i.e. Real Player, Quicktime,etc.) and never had a problem. A new window opens up with (in my case) a Quicktime player/progress bar and I can hear the music play almost immediately. Aside from scripting a custom mp3 player, is this an acceptable way of playing mp3s on a website?

Here’s why I ask:
A site I just built for someone doesnt quite work that way. My client says that Real Player is his default player for mp3s and the popup window reads “Error page not found”.

Can anyone point me to a tutorial that explains mp3 file-type associations and hopefully provides a solution to my clients errant popup?

My quick question: Do you work/ just upgraded to Windows XP SP 2? Because I have similar problem with PDF file too ( getURL (“my.pdf”,"_blank"). I t always work before and suddenly have similar problem like yours.

it seems IE has become stricter if it can’t figure out what type of file it is dealing with. I had similar trouble with a generated image and solved it by forcing the download with a header such as this and making sure no other headers were sent:

Content-Disposition: attachment; filename=“myimage.jpg”

this mean you would have to make a (simple) download page in PHP or some similar scripting language that you could call with the name of the file you want to open.

try the same movie in the FireFox browser (http://www.mozilla.org). 10 to 1 it will work fine there.

Hi tizzle,

I am interested with your solutions. Is it possible if I ask you to post me the PHP coded page taht you mentioned?

Thanks before

something like this should work. i made this up on the spot so it’s not tested but it gives the general idea.


<?php

$filename = $_REQUEST['filename'];

header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($filename));
header('Content-Disposition: attachment; filename=' . basename($filename ));
readfile($filename ); 

?>

please note that letting visitors open a file via a url is pretty insane from a security perspective so you should have some sort of check in there or at least only allow files to be opened from a certain ‘safe’ directory.

re: please note that letting visitors open a file via a url is pretty insane from a security perspective so you should have some sort of check in there or at least only allow files to be opened from a certain ‘safe’ directory.

okay, thats what I was worried about