title: Force download on a ftp:// link
body: <p>I have a PHP that scans the files in a remote NAS Hard Disk via FTP protocol, generates a json file and then via javascript I list those files in the browser. </p>
  
  <p>When the user click a link to a mp4, jpg and many browser-known formats, the browser opens te content instead of downloading it. </p>
  
  <p>Now, I know that with PHP or .htaccess I can change the headers to force the browser to download the file but the file is in a remote location and can only be access via FTP so I can't run PHP or .htaccess in it.</p>
  
  <p>I tried this header variations in PHP:</p>
  
  <pre><code>header("Content-Type: application/octet-stream");
  header("Content-Transfer-Encoding: Binary");
  header("Content-Disposition: attachment; filename=\"$file\""); 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>header("Content-Description: File Transfer"); 
  header("Content-Type: application/octet-stream"); 
  header("Content-Disposition: attachment; filename=\"$file\"");
  </code></pre>
  
  <p>or</p>
  
  <pre><code>header("Cache-Control: public");
  header("Content-Description: File Transfer");
  header("Content-Disposition: attachment; filename=$file");
  header("Content-Type: application/image");
  header("Content-Transfer-Encoding: binary");
  </code></pre>
  
  <p>all ending with:</p>
  
  <pre><code>header("Location: $url");
  </code></pre>
  
  <p>(url being <a href="ftp://user:password@dyndns.org/folder/file.mp4" rel="nofollow">ftp://user:password@dyndns.org/folder/file.mp4</a>)
  but it always opens the file in the browser instead of downloading (on recognized file extensions of course)</p>
  
  <p>Any ideas? Thanks</p>