douliedai4838 2018-08-29 17:00
浏览 289

ssh2_scp_send - 将整个本地文件夹内容上载到远程文件夹

I would like to use the ssh2_scp_send function to copy all the contents of a local folder to a folder on the remote computer.

I tried to do the way it shows in the example of the link below, but from what I realized I only copy file to file. http://php.net/manual/pt_BR/function.ssh2-scp-send.php

<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

ssh2_scp_send($connection, '/local/filename', '/remote/filename', 0644);
?>

I thought I'd put this together with a function that lists all the files and subfolders in a parent folder.

function listFolderFiles($dir){
    $ffs = scandir($dir);

    unset($ffs[array_search('.', $ffs, true)]);
    unset($ffs[array_search('..', $ffs, true)]);

    // prevent empty ordered elements
    if (count($ffs) < 1)
        return;

    echo '<ol>';
    foreach($ffs as $ff){
        echo '<li>'.$ff;
        if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);
        echo '</li>';
    }
    echo '</ol>';
}

listFolderFiles('Main Dir');

Source: https://stackoverflow.com/a/7121809/8442925

How could I redo this function above and include the ssh2_scp_send part? Could you give me a north or another method?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试