View Full Version : File corrupt when downloaded from php

08-28-2007, 06:01 AM
Not exactly sure how to go about fixing this so I
decided to ask here.

If i go to /song.mp3 it downloads and plays just fine
but if i use this php code.

$file = 'song.mp3';
_Download("".$file, $file);
function _Download($f_location,$f_name){
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Description: File Transfer');
header('Content-Type: audio/mpeg');
header('Content-Length: ' . filesize($f_location));
header('Content-Disposition: attachment; filename=' . basename($f_name));
?> Gotta remove some of the code once I get it working correctly...

The song downloads but is all skippy and corrupted
sounding. Anyone know how to fix this?


08-28-2007, 06:53 AM
Change the content-type header to "application/octet-stream" and test. If the stream is buggered, I'd say php errors are being written to the file.

08-29-2007, 07:32 AM
I use for file load :

$data = file_get_contents($f_location);
echo $data;

Textures (http://textures.z7server.com)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum