error handling - PHP return mp3 file -
hello guys!
i have little music app files loaded url "http://www.mymusicapp.com/get_song.php?name=some_music". locally app works fine! but, when put on server app generate error in browser console.
browser error uncaught invalidstateerror: attempt made use object not, or no longer, usable
my php code is...
$song_name = $_get['name']; $song_file = "{$_server['document_root']}/assets/musics/{$song_name}.mp3"; if( file_exists( $song_file ) ) { header("content-type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3"); header('content-length: ' . filesize($song_file)); header('content-disposition: attachment; filename="'.$song_name.'.mp3"'); header("content-transfer-encoding: binary"); header('x-pad: avoid browser bug'); readfile( $song_file ); }
Comments
Post a Comment