Force download

I ve tried the code taken from this older post :http://www.kirupaforum.com/forums/showthread.php?threadid=34856


<?php 
$filename = $_GET['filename']; 
if (ereg(".mp3$", $filename)) { 
header("Pragma: public"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Content-Type: application/force-download"); 
header("Content-Type: application/octet-stream"); 
header("Content-Type: application/download"); 
header("Content-Disposition: attachment; filename=".basename($filename).";"); 
header("Content-Transfer-Encoding: binary"); 
header("Content-Length: ".filesize($filename)); 
readfile("$filename"); 
} 
?> 

If my file is called “http://www.mydomain.com/my music.mp3” this script doesnt work.
Seems that spacing and distant file are not friend :frowning:

Local file + spaces = ok
distant file + nospace = ok

distant file + spaces = not ok

When i m calling the script, it makes me download a “my music.mp3” file (5ko) with this error message in it:

<br />
<b>Warning</b>: stat failed for http://www.mydomain.com/my music.mp3 (errno=2 - No such file or directory) in <b>d:\easyphp\www\download.php</b> on line <b>12</b><br />
<br />
<b>Warning</b>: Cannot add header information - headers already sent by (output started at d:\easyphp\www\download.php:12) in <b>d:\easyphp\www\download.php</b> on line <b>12</b><br />
<br />
<b>Warning</b>: readfile(“http://www.mydomain.com/my music.mp3”) - No such file or directory in <b>d:\easyphp\www\download.php</b> on line <b>13</b><br />

i’m going nuts :frowning: if someone has an idea it would be great, thanks.