title: PHP Header Content-Disposition: attachment forces .php file or inline
body: <p>I want to download a single .mp3 file from my site but when using this code it forces a .php in Firefox and Safari. But in chrome it will send force the file as inline and play on the page. How can i get them to actually download a .mp3 file?</p>
  
  <pre><code>$track = $_SERVER['QUERY_STRING'];
  
  if (file_exists("/home/user/gets/" .$track)) {
      header("Content-Type: audio/mpeg");
      header('Content-Length: ' . filesize($track));
      header('Content-Disposition: attachment; filename="test.mp3"');
      $str = "/home/user/gets/".$track;
      readfile($str); 
      exit;
  } else {
      header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
      echo "no file";
  }
  </code></pre>
  
  <p>I have also tried to download a .zip file as well and changing the Content-Type to application/ocetet-stream but it forces .php files on all browsers.</p>
  
  <pre><code>//$track = $_SERVER['QUERY_STRING'];
  $track = 'testfile.zip';
  if (file_exists("/home/user/gets/" .$track)) {
      header("Content-Type: application/octet-stream");
      header('Content-Length: ' . filesize($track));
      header('Content-Disposition: attachment; filename="test.mp3"');
      $str = "/home/user/gets/".$track;
      readfile($str); 
      exit;
  } else {
      header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
      echo "no file";
  }
  </code></pre>