title: Uploading files with SFTP
body: <p>I have successfully uploaded files over ftp, but I now need to do via SFTP. I can successfully connect to the remote server, create a file and write to it, but I am unable to upload an existing file from my local server to the remote server. Is ftp_put not firing with an sftp connection?</p>
  
  <p>My code used to write a file :</p>
  
  <pre><code>//Send file via sftp to server
  
  $strServer = "*****";
  $strServerPort = "****";
  $strServerUsername = "*****";
  $strServerPassword = "*****";
  $csv_filename = "Test_File.csv";
  
  //connect to server
  $resConnection = ssh2_connect($strServer, $strServerPort);
  
  if(ssh2_auth_password($resConnection, $strServerUsername, $strServerPassword)){
      //Initialize SFTP subsystem
  
      echo "connected";
      $resSFTP = ssh2_sftp($resConnection);    
  
      $resFile = fopen("ssh2.sftp://{$resSFTP}/".$csv_filename, 'w');
      fwrite($resFile, "Testing");
      fclose($resFile);                   
  
  }else{
      echo "Unable to authenticate on server";
  }
  </code></pre>
  
  <p>Has anyone had any success in grabbing a local file and uploading via a method such as above with sftp? An example would be greatly appreciated.</p>
  
  <p>Thanks</p>