title: PHP Force Download File Name with Spaces
body: <p>Ok I seem to be having an issue with making my script download the file with the proper file name.</p>
  
  <p>If I strip spaces and dashes which looks like this</p>
  
  <pre><code>if($type == 'mc'){
      $file_name = $_POST['Ids'];
      $file_name = str_replace('-', '', $file_name);
      $file_name = str_replace(' ', '&amp;amp;', $file_name);
      $url = base64_decode($stream);
      $file_url = "scd.php?stream=".$url."&amp;name=".$file_name."";
      $url = array('url' =&gt; $file_url);
      echo json_encode($url);
  }
  </code></pre>
  
  <p>Here is <code>scd.php</code></p>
  
  <pre><code>&lt;?php
  $file = $_GET['stream'];
  $name = $_GET['name'];
  header("Content-type: application/x-file-to-save");
  header("Content-Disposition: attachment; filename=".$name.".mp3");
  readfile($file);
  exit();
  ?&gt;
  </code></pre>
  
  <p>It will force the download but it will only save the first word in the name that is sent. So say the name is <code>Your Song Here</code> it wants to save it as <code>Your.mp3</code> but if I remove the <code>str_replace</code> from the <code>$file_name</code> variable then it will try to save the file as <code>Your</code> with no extension but still only the first word.</p>
  
  <p>I need it to pass the entire <code>$file_name</code> variable ex. <code>Your Song Here.mp3</code> and still save it as an MP3 file.</p>
  
  <p>I am not quite sure what I am doing wrong</p>