title: Upload a local file from application via web server with PHP code to FTP server
body: <p>I would like some help concerning how to upload a local file from an application to FTP using PHP code. 
  I am an amateur programmer that can read very basic code structure. So please avoid using programming terms!</p>
  
  <p>I am developing a simple Windows application (through visual programming). The app will upload a local file to my FTP server through a web site (e.g. <a href="http://www.mysite/folder/ftp.php" rel="nofollow noreferrer">http://www.mysite/folder/ftp.php</a>). I am doing this in order to avoid including my FTP login details in the app's code.  </p>
  
  <p>I have found a PHP code that seems to work, but I do not understand how to include my local file's path in the code (e.g. <code>C:\User\Desktop\myfile.txt</code>). I wish to use the following code, which I found pretty easy to understand. I just don't know how to specify the path of the local file as well as the path where this file will be uploaded.  Finally, the local path will be specified in the link (eg <a href="http://www.mysite/folder/ftp.php?localpath=...." rel="nofollow noreferrer">http://www.mysite/folder/ftp.php?localpath=....</a>.), so I think that I should use a <code>$file=$_GET['file'];</code> instead of <code>$file = ".....";</code>.</p>
  
  <pre><code>&lt;?php 
  $ftp_server=""; 
  $ftp_user_name=""; 
  $ftp_user_pass=""; 
  $file = "";//tobe uploaded 
  $remote_file = ""; 
  
  // 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); 
  
  // upload a file 
  if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { 
      echo "successfully uploaded $file\n"; 
      exit; 
  } else { 
      echo "There was a problem while uploading $file\n"; 
      exit; 
      } 
  // close the connection 
  ftp_close($conn_id); 
  ?&gt;
  </code></pre>