【发布时间】:2018-08-08 21:53:51
【问题描述】:
我正在尝试为多个服务器创建在线编辑器。我想在服务器上编辑一个自定义文件,我需要通过 sftp 获取它。我当前的代码如下所示:
<?php
$user="user";
$pass = 'pass';
$c = curl_init("sftp://$user:$pass@0.0.0.0/path/to/file/file.txt");
curl_setopt($c, CURLOPT_PORT, 3206);
curl_setopt($c, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
curl_setopt($c, CURLOPT_FILE, $fh);
curl_exec($c);
curl_close($c);
//the next line is not working and from now on am I stuck
$text = file_get_contents($fh);
?>
<!-- HTML form -->
<form action="" method="post">
<textarea name="text"><?php echo htmlspecialchars($text) ?></textarea>
<input
type="submit" />
<input type="reset" />
</form>
我想在网站上编辑此文件,然后将其重新上传到同一目录中的 sftp 服务器(覆盖现有文件)。我不知道如何继续。谢谢您的帮助。
【问题讨论】: