我似乎无法使用 cURL 通过 SFTP 下载文件。
$c = curl_init("sftp://$user:$pass@/someserver.com/$filename");
$fh = fopen($filename, 'w') or die($php_errormsg);
curl_setopt($c, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
curl_setopt($c, CURLOPT_FILE, $fh);
curl_exec($c);
curl_close($c);
我做错了什么吗?非常感谢您的帮助
米歇尔
最佳答案
是的,您的域名有一个/。
$c = curl_init("sftp://$user:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e0c490819393a0938f8d85938592968592ce838f8d" rel="noreferrer noopener nofollow">[email protected]</a>/$filename");
$fh = fopen($filename, 'w') or die($php_errormsg);
curl_setopt($c, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
curl_setopt($c, CURLOPT_FILE, $fh);
curl_exec($c);
curl_close($c);
关于php - 使用 SFTP 和 cURL 获取文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8044450/