我正在尝试使用 PHP 中的 cURL 库从远程服务器 SFTP 获取文件,如下所示。我得到一个no such file exists
错误。任何想法我做错了什么?
<html>
<body>
<?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);
?>
</body>
</html>
错误:
Warning: fopen(="/opt/vmstat/vmstat_file): failed to open stream: No such file or directory in C:\inetpub\wwwroot\sftp.php on line 9