put_file
put_file($server,$local_file,$remote_file,$flag_fail_exist=true,$timeout=3000); - Закачать файл на FTP серверФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
<?php // Scenario: Upload a file 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 file echo "\n\nExample 1: Upload file\n"; $localSourceFile = "test/put_test.txt"; $remoteDestFile = "test.txt"; $overwrite = false; echo "2. Upload file: "; $putFileResult = WEB::$webdav->put_file($server, $localSourceFile, $remoteDestFile, $overwrite); echo $putFileResult . "\n"; // Step: Get file to verify upload echo "3. Get file (always overwrite): "; $localDestFile = "test/get_test.txt"; $getFileResult = WEB::$webdav->get_file($server, $remoteDestFile, $localDestFile, false); echo $getFileResult . "\n"; // Step: Get file conditionally echo "4. Get file (only if not exists locally): "; $getConditionalResult = WEB::$webdav->get_file($server, $remoteDestFile, $localDestFile, true); if (!$getConditionalResult) echo "File already exists locally\n"; // Step: Disconnect from all servers echo "5. 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:7013" 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>"); # 1 echo("1. Запишем файл : "); echo(webdav.put_file(server,"test\\put_test.txt","test.txt",false),"<br>"); # 2 echo("2. Получим файл в любом случае : "); echo(webdav.get_file(server,"test.txt","test\\get_test.txt",false),"<br>"); # 3 echo("3. Получим файл, только если такого нет на локальной машине : "); if not webdav.get_file(server,"test.txt","test\\get_test.txt",True): echo("уже есть\n"); # 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 = "xxx@yandex.ru"; var password = "xxx"; // 1 echo("1. Соединится с сервером : "+server+" : "); echo(webdav.connect(server,login,password)+"<br>"); // 1 echo("1. Запишем файл : "); echo(webdav.put_file(server,"test\\put_test.txt","test.txt",false)+"<br>"); // 2 echo("2. Получим файл в любом случае : "); echo(webdav.get_file(server,"test.txt","test\\get_test.txt",false)+"<br>"); // 3 echo("3. Получим файл, только если такого нет на локальной машине : "); if (!webdav.get_file(server,"test.txt","test\\get_test.txt",true)) echo("уже есть\n"); // 4 echo("4. Отсоединится от всех серверов : "); echo(webdav.disconnect_all()); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7028"; 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_file(server,"test\\put_test.txt","test.txt",false)+"<br>"); // 2 echo("2. Получим файл в любом случае : "); echo(webdav.get_file(server,"test.txt","test\\get_test.txt",false)+"<br>"); // 3 echo("3. Получим файл, только если такого нет на локальной машине : "); if (!webdav.get_file(server,"test.txt","test\\get_test.txt",true)) echo("уже есть\n"); // 4 echo("4. Отсоединится от всех серверов : "); echo(webdav.disconnect_all()); // конец echo("\n"); // Quit app.quit();
=============================================
webdav Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.