title: download file from remote server by php?
body: <p>Someone tells me. if it is possible for me to download a specific file from a remote server at my location via php?</p>
  
  <p>I've tried codes and I couldn't</p>
  
  <pre><code>    &lt;?php
  
  // define some variables
  $local_file = '/httpdocs/teste.pdf';
  $server_file = 'teste.pdf';
  $ftp_server="209.126.127.143";
  $ftp_user_name="username";
  $ftp_user_pass="password";
  
  $conn_id = ftp_connect($ftp_server);
  
  // login with username and password
  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  
  // try to download $server_file and save to $local_file
  if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
      echo "Successfully written to $local_file\n";
  }
  else {
      echo "There was a problem\n";
  }
  // close the connection
  ftp_close($conn_id);
  
  ?&gt;
  </code></pre>