title: How to use the content-disposition header to set a downloaded UTF-8 filename?
body: <p>I am storing my files on Amazon Cloud Drive. And there are option for setting <code>response-content-disposition</code> to direct links from Amazon.</p>
  
  <p>From the API:</p>
  
  <blockquote>
    <p><code>response-content-disposition</code>: (Optional) If specified, the content-disposition of the response will be set to this value</p>
  </blockquote>
  
  <p>I need to set it download mp3 files. I don't need to play it on browser.</p>
  
  <p>And I want to set downloaded file name: <code>Эльбрус Джанмирзоев - Кавказская любовь.mp3</code></p>
  
  <p>I tried many ways... Urlencode... Urlencode + http build query etc...</p>
  
  <p>But now the result is: <code>Эльбрус+Джанмирзоев+-+Кавказская+любовь.mp3</code> when downloading files.</p>
  
  <p>And here is my php code:</p>
  
  <pre><code>&lt;?php
      function file_generate_download_link($filename = false, $force = true)
      {
              $json['tempLink'] = 'https://content-na.drive.amazonaws.com/cdproxy/templink/iTwUqoQ3cJXOpj6T8SCDmKwtF37TAENiSLQzy7pTSbkFfJttb';
              $url = $json['tempLink'];
              if($force)
              {
                  $data['download'] = 'true';
              }
              if($filename)
              {               
                  $data['response-content-disposition'] = ' attachment; filename*=UTF-8\'\''.urlencode($filename).'';
              }
              if(isset($data)) {
                  $data = http_build_query($data);
                  $url .= '?' . $data;
              }
              return $url;
  
      }
  
      echo file_generate_download_link($filename = 'Эльбрус Джанмирзоев - Кавказская любовь.mp3');
  ?&gt;
  </code></pre>
  
  <p>This code returns me this link:</p>
  
  <p><a href="https://content-na.drive.amazonaws.com/cdproxy/templink/iTwUqoQ3cJXOpj6T8SCDmKwtF37TAENiSLQzy7pTSbkFfJttb?download=true&amp;response-content-disposition=+attachment%3B+filename%2A%3DUTF-8%27%27%25D0%25AD%25D0%25BB%25D1%258C%25D0%25B1%25D1%2580%25D1%2583%25D1%2581%2B%25D0%2594%25D0%25B6%25D0%25B0%25D0%25BD%25D0%25BC%25D0%25B8%25D1%2580%25D0%25B7%25D0%25BE%25D0%25B5%25D0%25B2%2B-%2B%25D0%259A%25D0%25B0%25D0%25B2%25D0%25BA%25D0%25B0%25D0%25B7%25D1%2581%25D0%25BA%25D0%25B0%25D1%258F%2B%25D0%25BB%25D1%258E%25D0%25B1%25D0%25BE%25D0%25B2%25D1%258C.mp3" rel="nofollow">https://content-na.drive.amazonaws.com/cdproxy/templink/iTwUqoQ3cJXOpj6T8SCDmKwtF37TAENiSLQzy7pTSbkFfJttb?download=true&amp;response-content-disposition=+attachment%3B+filename%2A%3DUTF-8%27%27%25D0%25AD%25D0%25BB%25D1%258C%25D0%25B1%25D1%2580%25D1%2583%25D1%2581%2B%25D0%2594%25D0%25B6%25D0%25B0%25D0%25BD%25D0%25BC%25D0%25B8%25D1%2580%25D0%25B7%25D0%25BE%25D0%25B5%25D0%25B2%2B-%2B%25D0%259A%25D0%25B0%25D0%25B2%25D0%25BA%25D0%25B0%25D0%25B7%25D1%2581%25D0%25BA%25D0%25B0%25D1%258F%2B%25D0%25BB%25D1%258E%25D0%25B1%25D0%25BE%25D0%25B2%25D1%258C.mp3</a></p>
  
  <p>If I enter this link Chrome saves this file with this name:</p>
  
  <p><code>Эльбрус+Джанмирзоев+-+Кавказская+любовь.mp3</code></p>
  
  <p>But I need excatly save file with this name:</p>
  
  <p><code>Эльбрус Джанмирзоев - Кавказская любовь.mp3</code></p>
  
  <p>Where is my mistake?</p>