I have a small music application where files are loaded from a URL like " link ".
Locally the application works very well.
But when I put it on the server my application generates an error in the browser console.
Uncaught InvalidStateError: Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable.
My PHP code:
$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 );
}