i'm wondering how to serve a file while i'm converting it, to lower thhe waiting time of the client. I'v tried the chunked header in php, but only the first bytes of the file are downloaded.
header('Transfer-Encoding: chunked');
header('Content-Type:audio/mpeg');
header('Connection: keep-alive');
header('Content-Disposition: attachment; filename="' . basename($mp3File) . '"');
header('Connection: close');
ob_clean();
flush();
$buffer = '';
$handle = fopen($mp3File, 'rb');
if($handle === false){
return false;
}
while(!feof($handle)){
$buffer = fread($handle, 8192);
echo sprintf("%x\r\n", strlen($buffer));
echo $buffer;
echo "\r\n";
ob_flush();
flush();
}
echo sprintf("%x\r\n", 0);
echo "\r\n";
fclose($handle);
So i'm asking for some help here, in case some one already found some trick or whatever.