title: file uploading using ftp_put
body: <p>I have solved my original question below. What is the best method if I need to insert a progress bar for the file uploader? Using the ftp_put method, doesn't allow to get a response from the server until the file is successfully uploaded.</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p>I'm trying to upload a file using <strong>ftp_put</strong> and for some reason when I run the code through localhost, it gives me the below error:</p>
  
  <blockquote>
    <p>Warning: ftp_put(): Can't open that file: Is a directory in C:\xampp\htdocs\ftp\upload_file.php on line 25</p>
  </blockquote>
  
  <pre><code>&lt;form action="upload_file.php" enctype="multipart/form-data" method="post"&gt;
  &lt;input name="uploadedfile" type="file" /&gt;
  &lt;input name="submit" type="submit" value="Upload File" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP Code:</p>
  
  <pre><code>&lt;?php
  $ftp_server = "";
  $ftp_user_name = "";
  $ftp_user_pass = "";
  $destination_file = "/public_html/testing/";
  $source_file = $_FILES['uploadedfile']['tmp_name']; 
  
  // set up basic connection
  $conn_id = ftp_connect($ftp_server);
  ftp_pasv($conn_id, true); 
  
  // login with username and password
  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 
  
  // check connection
  if ((!$conn_id) || (!$login_result)) { 
      echo "FTP connection has failed!";
      echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
      exit; 
  } else {
      echo "Connected to $ftp_server, for user $ftp_user_name";
  }
  
  // upload the file
  $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); 
  
  // check upload status
  if (!$upload) { 
      echo "FTP upload has failed!";
  } else {
      echo "Uploaded $source_file to $ftp_server as $destination_file";
  }
  // close the FTP stream 
  ftp_close($conn_id);
  ?&gt;
  </code></pre>
  
  <p>Thank you.</p>