title: how to SFTP get file using cURL with PHP
body: <p>I am tryin to use the cURL library in PHP to SFTP get file from a remote server as follows. I get a <code>no such file exists</code> error. Any ideas what I am doing wrong?</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  &lt;?php
  $user="username";
  $pass="password";
  $filename="/opt/vmstat/vmstat_file";
  $c = curl_init("sftp://$user:$pass@server1/$filename");
  $fh = fopen($filename, 'r') or die($php_errormsg);
  curl_setopt($c, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
  curl_setopt($c, CURLOPT_FILE, $fh);
  curl_exec($c);
  curl_close($c);
  
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>Warning: fopen(="/opt/vmstat/vmstat_file): failed to open stream: No such file or directory in C:\inetpub\wwwroot\sftp.php on line 9
  </code></pre>