title: PHP upload multiple files using FWRITE and SSH2
body: <p>I'm trying to upload multiple files to a SFTP site from a local directory.</p>
  
  <p>I can get it to work for a single file but I would like to be able to upload multiple files which have variables names too.</p>
  
  <pre><code>$localFile_xml = "C:\xml\Race_" . $value; 
  chdir($localFile_xml); 
  
  
  //This successfully lists the files
  foreach (glob("*.xml") as $filename) {
      echo "$filename size " . filesize($filename) . "\n";
  }
  
  $remote_XMLfiles = "/FTP/XML/Race_" . $value;
  
  $xmlstream = fopen("ssh2.sftp://$sftp" . $remote_XMLfiles, 'w');
  
  foreach (glob("*.xml") as $filename) {
      $xmlfile = file_get_contents($localFile_xml);
      fwrite($xmlstream, $xmlfile);
      fclose($xmlstream);
  
  }
  </code></pre>
  
  <p>I believe its there but I cannot get the last bit correct.</p>
  
  <p>Thank you so much in advance</p>