title: Symfony2 : how to force download
body: <p>I am trying to make a link to download a file with symfony2. It does download a file, but it's useless as it is zero octect. I don't know how to make it work. Does anybody know how to do?</p>
  
  <p>The file is in <code>web/uploads/documents/</code>.</p>
  
  <p>Here is the code in the controller:</p>
  
  <pre><code>// here I get the name of the file
  
    $response = new Response();
    $response-&gt;headers-&gt;set('Content-type', 'application/octet-stream');
    $response-&gt;headers-&gt;set('Content-Disposition', sprintf('attachment; filename="%s"', $filename));
  
    return $response;
  </code></pre>
  
  <p>I tried to write the whole path instead of <code>$filename</code> but it changes all the slashes in underscore.</p>