text: Q:
  
  Unable to connect a server with FTP and PHP
  
  I am unable to connect to a FTP server when i am connecting it through our PHP code. Most embarrassing thing is that i get only false when trying to connect server with ftp_connect() method. No errors are reported. This is my first time when i am working with FTP in PHP. if anyone who have previously worked on it can help me out here. Here is my code :
  /* Source File Name and Path */    
  $remote_file = $_SERVER['DOCUMENT_ROOT'] ."/some-folder/file.txt";
  
  /* New file name and path for this file */
  $ftp_host = 'ftp://targetserver.com/some folder/'; 
  $ftp_user_name = 'user';
  $ftp_user_pass = 'XXXXX';
  
  /* New file name and path for this file */
  $local_file = 'ftp://targetserver.com/some-folder/file.txt';
  
  /* Connect using basic FTP */
  $connect_it = ftp_connect( $ftp_host, 21);
  var_dump($connect_it);
  
  /* Login to FTP */
  $login_result = ftp_login( $connect_it, $ftp_user_name, $ftp_user_pass );
  
  /* Download $remote_file and save to $local_file */
  if ( ftp_get( $connect_it, $local_file, $remote_file, FTP_BINARY ) ) {
       echo "Successfully written to $local_file\n";
  }
  else {
      echo "There was a problem\n";
  }
  
  /* Close the connection */
  ftp_close( $connect_it );
  
  A:
  
  Actually getting false means that your ftp client couldn't connect to the server for some reason
  $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
  
  The best to do before you dive into php debugging is to try out another ftp client such as https://filezilla-project.org/ and see if all works fine, if not you will have saved your time because the issue not coming from your php script.
  
  UPDATE 1
  
  Then try this:
  $ftp_host = 'targetserver.com';
  
  http://php.net/manual/en/function.ftp-connect.php#refsect1-function.ftp-connect-parameters
  The FTP server address. This parameter shouldn't have any trailing slashes and shouldn't be prefixed with ftp://.
  
  And as for local_file and remote_file, they must be paths and not urls
  http://php.net/manual/en/function.ftp-get.php#refsect1-function.ftp-get-examples
  
  