php - MIME Type 'application/octet-stream' is switched to 'text/html' in my server. How to prevent? -
i trying download .mp3 file server when pass below code , prints file @ browser screen in binary converting content-type: text/html;charset=utf-8.
if tried same code other server, runs content-type: application/octet-stream. can code 100% valid (code in php).
so problem in server configuration or other issue? please me resolve problem.
<?php set_time_limit(0); $url = 'https://abcdefgh.s3.amazonaws.com/audio/1431428586_z3ptl.mp3'; $file = basename($url); $fp = fopen($file, 'w'); $ch = curl_init($url); curl_setopt($ch, curlopt_file, $fp); $data = curl_exec($ch); curl_close($ch); fclose($fp); header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename='.basename($file)); header('content-transfer-encoding: binary'); header('expires: 0'); header('cache-control: must-revalidate'); header('pragma: public'); header('content-length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; ?>
yes, server configuration. firstly, try upload original mp3 server , access http://yourserver.com/file.mp3. if can, wrong php, if cannot - tweak server.
Comments
Post a Comment