title: Why "ftp_fget" is returning "bind() failed: Permission denied (13)" in php?
body: <p>I'm trying to read a csv file on a distant server using the <code>ftp_fget</code> and <code>fgetcsv</code> functions. I already practice this multiple times when reading files on distant servers and until now it works fine.</p>
  
  <p>I can't figure out why ftp_fget is returning this error: <code>bind() failed: Permission denied (13)</code>.
  Furthermore, I can't find any real explanations about this error message too.</p>
  
  <p>My client who gave me distant server access said it's a <em>Windows Server</em>.</p>
  
  <pre><code>$distant_folder = "/myfolder/";
  $filename = "myfile.csv";
  
  $ftpstream = ftp_connect($ftp_server); 
  $login = ftp_login($ftpstream, $ftp_user, $ftp_pass);
  
  if($login){
      $tmp_handle = fopen('php://temp', 'r+');
  
      if (ftp_fget($ftpstream, $tmp_handle, $distant_folder.$filename, FTP_ASCII)){
          // do stuff with fgetcsv()...
      }
  }
  </code></pre>
  
  <p><em>Please notice values of the ftp server variables are hidden for confidential reasons.</em></p>
  
  <p><strong>EDIT : I found a solution!</strong></p>
  
  <p>I used <code>ftp_pasv($ftpstream, true);</code> between <code>ftplogin()</code> and <code>ftp_fget()</code> functions.</p>