humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | Changelog

put_folder

put_folder($server,$local_folder,$remote_folder,$timeout=3000); - Закачать папку на FTP сервер

Функция на вход принимает параметры:

  • $server – адрес FTP сервера
  • $local_folder – абсолютный/относительный путь к локальной папке
  • $remote_folder – путь к папке на сервере FTP
  • $timeout – интервал ожидания выполнения операции, сек

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • true – успешно
  • false – не удалось

    Пример использования
    <?php
    // Scenario: Upload a folder to a WebDAV server
    
    $xhe_host = getenv("RPABOT_HOST_URL");
    if (!isset($path)) {
      // Path to the init.php file for connecting to the XHE API
      $path = "../../../Templates/init.php";
      // Including init.php grants access to all classes and functionality for working with the XHE API
      require($path);
    }
    
    // Start
    echo "\n<font color=blue>webdav->" . basename(__FILE__) . "</font>\n";
    
    // Account credentials
    $server = "https://webdav.yandex.ru";
    $login = "xxx@yandex.ru";
    $password = "xxx";
    
    // Step: Connect to WebDAV server
    echo "1. Connect to server: " . $server . " : ";
    $connectResult = WEB::$webdav->connect($server, $login, $password);
    echo $connectResult . "\n";
    
    // Example 1: Upload folder
    echo "\n\nExample 1: Upload folder\n";
    $localSourceFolder = "test";
    $remoteDestFolder = "test";
    echo "2. Upload folder: ";
    $putFolderResult = WEB::$webdav->put_folder($server, $localSourceFolder, $remoteDestFolder);
    echo $putFolderResult . "\n";
    
    // Step: Disconnect from all servers
    echo "3. Disconnect from all servers: ";
    $disconnectResult = WEB::$webdav->disconnect_all();
    echo $disconnectResult . "\n";
    
    // End
    echo "\n";
    
    // Quit the application
    WINDOW::$app->quit();
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7039"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>ftp.xxxxxxxxx</font><hr>")
    
    # аккаунт
    server = "https://webdav.yandex.ru";
    login = "xxx@yandex.ru";
    password = "xxx";
    
    # 1 
    echo("1. Соединится с сервером : "+server+" : ");
    echo(webdav.connect(server,login,password),"<br>");
    
    # 2
    echo("2. Запишем  : ");
    echo(webdav.put_folder(server,"test","test"),"<br>");
    
    # 3
    echo("3. Получим : ");
    echo(webdav.get_folder(server,"test","test_get"),"<br>");
    
    # 4
    echo("4. Отсоединится от всех серверов : ");
    echo(webdav.disconnect_all());
    
    # конец
    echo("<hr><br>")
    
    # Quit
    app.quit()
    #region using
    
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
    
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
    
    #endregion
    
     class Program:XHEScript
     {
    	  static void Main(string[] args)
    	  {
    			// init XHE
    			XHEScript.server = Environment.GetEnvironmentVariable("RPABOT_HOST_URL");
    			InitXHE();
    
    			// начало
    			echo("<hr><font color=blue>ftp.put_file</font><hr>");
    				
    			// аккаунт
    			var server = "https://webdav.yandex.ru";
    			var login = "bigfozzy@yandex.ru";
    			var password = "dvikwkkuiiuneept";
    
    			// 1 
    			echo("1. Соединится с сервером : "+server+" : ");
    			echo(webdav.connect(server,login,password)+"<br>");
    
    			// 2
    			echo("2. Запишем : ");
    			echo(webdav.put_folder(server,"test","test")+"<br>");
    
    			// 3
    			echo("3. Получим : ");
    			echo(webdav.get_folder(server,"test","test_get")+"<br>");
    
    			// 4 
    			echo("4. Отсоединится от всех серверов : ");
    			echo(webdav.disconnect_all());
    
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    // подключим функциональные объекты, если еще не подключен
    xhe_host="127.0.0.1:7039";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>ftp.put_file</font><hr>");
    
    // аккаунт
    server = "https://webdav.yandex.ru";
    login = "xxx@yandex.ru";
    password = "xxx";
    
    // 1 
    echo("1. Соединится с сервером : "+server+" : ");
    echo(webdav.connect(server,login,password)+"<br>");
    
    // 1
    echo("1. Запишем : ");
    echo(webdav.put_folder(server,"test","test")+"<br>");
    
    // 2 
    echo("2. Получим  : ");
    echo(webdav.get_folder(server,"test","test_get")+"<br>");
    
    // 3
    echo("3. Отсоединится от всех серверов : ");
    echo(webdav.disconnect_all());
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

    =============================================
    webdav    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .