downloading - Start serving file while converting it [PHP] -
i'm wondering how serve file while i'm converting it, lower thhe waiting time of client. i'v tried chunked header in php, first bytes of file 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 here, in case 1 found trick or whatever.
Comments
Post a Comment