Having troubles naming my downloaded file with Header!!

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
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Having troubles naming my downloaded file with Header!!

Post by psychotomus »

I am trying to name the file by the title with .mp3.. It only takes the first word of the title and doesn't even give it the file extension .mp3

Code: Select all

	
$fsize = filesize(cleanData($SEARCH->url)); 
    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false); // required for certain browsers
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=". cleanData($SEARCH->title). ".mp3;");
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".$fsize);
    ob_clean();
    flush();
    readfile(cleanData($SEARCH->url));
 
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Re: Having troubles naming my downloaded file with Header!!

Post by psychotomus »

Problem fixed but now a new problem arises..

Script works perfect in FireFox. When using IE, it will not download the file. Its always 0kb... Any ideas?

Code: Select all

	$SEARCH = mysql_fetch_object($s_query);
	$fsize = filesize(cleanData($SEARCH->url)); 
    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false); // required for certain browsers
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=" . str_replace(" ", "_",$SEARCH->title) . ".mp3;");
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".$fsize);
    ob_clean();
    flush();
    readfile(cleanData($SEARCH->url)); 
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Re: Having troubles naming my downloaded file with Header!!

Post by psychotomus »

anybody?
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Re: Having troubles naming my downloaded file with Header!!

Post by psychotomus »

Nobody? =) I still can't figure it out.. ;]
Post Reply