title: Not able to change directory through ftp in php
body: <p>I am trying to change the directory with <code>ftp_chdir</code> and it shows me the error:</p>
  
  <blockquote>
    <p>no such file or directory</p>
  </blockquote>
  
  <p>But the directory is available at the server side.  What am I doing wrong?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
  @session_start();
  error_reporting(0);
  // define some variables
  $local_file = $_GET['f'];
  $server_file = $_GET['f'];
  $ftp_user_name='abcd';
  $ftp_user_pass='abcd';
  $ftp_server='abcd';
  // set up basic connection
  $conn_id = ftp_connect($ftp_server);
  
  // login with username and password
  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  
  if (ftp_chdir($conn_id, $_SESSION['SITE_IMG_PATH']."x_directory/")) {
  echo 'Directory change';
  
  } else { 
  echo "Couldn't change directory\n :".ftp_pwd($conn_id);
  print_r (error_get_last());
  }
  
  
   // try to download $server_file and save to $local_file
   if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
  echo "success";
  } else {
  echo "No";
  }
  
   // close the connection
   ftp_close($conn_id);
  
  ?&gt;
  </code></pre>
  
  <p>It shows me the error:</p>
  
  <blockquote>
    <p>Couldn't change directory</p>
  </blockquote>
  
  <p>my path is
  <code>/home/website/public_html/upload/x_directory</code></p>