如何使用phpseclib将文件夹上传到服务器?
问题描述:
我使用phpseclib连接到服务器并使用\ Net_SFTP在服务器上上传文件。 但是如何上传一个大目录?我使用的Symfony Finder来收集所有本地文件路径的目录:如何使用phpseclib将文件夹上传到服务器?
$finder = new Finder();
$files = $finder
->files()
->in($local);
foreach ($files as $file) {
$from = $file->getRealPath();
$to = str_replace($local, '', $from);
$to = rtrim($remote, '/') . '/' . ltrim($to, '/');
$sftp->put($to, $from, NET_SFTP_LOCAL_FILE);
}
但是上传只有root文件。 phpseclib不会为新文件创建子目录。
如何使用phpseclib上载服务器上的文件夹?
答
尝试在每个放置之前做一个chdir()
。