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

list_files

list_files($server,$folder=""); - FTP

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

  • $server FTP
  • $folder FTP

    :
  • / null

    Пример использования
    <?php
    // Scenario: List files in a directory on FTP 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);
    }
    
    // Beginning
    echo "\n<font color=blue>ftp->".basename (__FILE__)."</font>\n";
    
    // FTP account
    $ftp_server = "ftp://127.0.0.1";
    $login = "test";
    $password = "test";
    $port = "";
    $is_passive = true;
    $timeout = 3;
    $encoding = "";
    
    // Step: Connect to FTP server
    echo "1. Connect to FTP server: ".$ftp_server." : ";
    echo WEB::$ftp->connect($ftp_server, $login, $password, $port,  $is_passive, $timeout, $encoding) . "\n";
    
    // Example 1: Get list of files in root directory on FTP server
    $directoryPath = ".";
    echo "\n\nExample 1: Get list of files in root directory on FTP server: \n";
    var_export(WEB::$ftp->list_files($ftp_server, $directoryPath));
    
    // Step: Disconnect from all FTP servers
    echo "2. Disconnect from all FTP servers: ";
    echo WEB::$ftp->disconnect_all();
    
    // End
    echo "\n\n";
    
    // Quit
    WINDOW::$app->quit();
    ?>
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7026"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>ftp.list_files</font><hr>")
    
    # FTP аккаунт
    ftp_server = "ftp://127.0.0.1"
    login = "test"
    password = "test"
    port = 21
    is_passive = True
    timeout = 3
    encoding = ""
    
    # 1
    echo("1. Соединится с FTP сервером '" + ftp_server + "': ")
    echo(ftp.connect(ftp_server, login, password, port , is_passive, timeout, encoding), "\n")
    
    # 2 
    echo("2. Получим список файлов в корневой папке на FTP сервере:")
    echo(ftp.list_files(ftp_server,"."), "\n")
    
    
    # 3
    echo("3. Отсоединится от всех FTP серверов: ")
    echo(ftp.disconnect_all(), "\n")
    
    # конец
    
    # 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
    			server = "127.0.0.1:7026";
    			InitXHE();
    
    			// начало
    			echo("<hr><font color=blue>ftp.list_files</font><hr>");
    				
    			// FTP аккаунт
    			string ftp_server = "localhost";
    			string login = "test";
    			string password = "test";
    			int port = 21;
                bool is_passive = true;
                int timeout = 3;
                string encoding = "";
    
    			// 1
    			echo("1. Соединится с сервером '" + ftp_server + "': ");
    			echo(ftp.connect(ftp_server, login, password, port, is_passive, timeout, encoding) + "\n");
    
    			// 2 
    			echo("2. Получим список файлов в корневой папке на FTP: ");
    			echo(ftp.list_files(ftp_server, ".") + "\n");
    
    			// 3
    			echo("3. Отсоединится от всех FTP серверов : ");
    			echo(ftp.disconnect_all() + "\n");
    			
    			// конец
    
    			app.quit();            
    	  }
    }
    // подключим функциональные объекты, если еще не подключен
    xhe_host="127.0.0.1:7026";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>ftp.create_directory</font><hr>");
    
    // FTP аккаунт
    const ftp_server = "ftp://127.0.0.1";
    const login = "test";
    const password = "test";
    const port = "";
    let is_passive = true;
    let timeout = 3;
    const encoding = "";
    
    // 1
    echo("1. Соединится с FTP сервером '" + ftp_server + "': ");
    echo(ftp.connect(ftp_server, login, password, port,  is_passive, timeout, encoding) + "\n");
    
    // 2 
    echo("2. Получим список файлов в корневой папке на FTP сервере: ");
    echo(ftp.list_files(ftp_server, ".") + "\n");
    
    // 3 шаг
    echo("3. Отсоединится от всех FTP серверов: ");
    echo( ftp.disconnect_all() + "\n");
    
    // конец
    
    // Quit
    app.quit();

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