简体   繁体   English

使用php自动传输文件

[英]automated file transfer using php

I need the info on the following work process and how I can execute it. 我需要以下工作流程以及如何执行的信息。

I can't share in details on what the work is but here is the work process. 我无法详细说明工作是什么,但这是工作过程。

I will have admin panel on one server and user interface on another. 我将在一台服务器上使用管理面板,在另一台服务器上使用用户界面。 Everyday users will log in to admin panel and create images that will be shown on the user interface. 每天,用户将登录到管理面板并创建将在用户界面上显示的图像。 This consists of database update and several image files. 这由数据库更新和几个映像文件组成。

Once the work is done, I will need those files to be transferred over to another server. 工作完成后,我需要将这些文件传输到另一台服务器。 It would be best if it can be done with a click of a button. 最好可以通过单击按钮来完成。

All the files will be in one folder and that folder will need to be transferred. 所有文件都将在一个文件夹中,并且该文件夹将需要传输。

Also the files that are created are close to 100MB so if it is possible can SSH be used to transfer the files automatically? 另外,创建的文件接近100MB,因此,如果可以的话,可以使用SSH自动传输文件吗?

If you use exec() or system() you can make calls to the shell directly to transfer in any way you like. 如果您使用exec()system() ,则可以直接调用Shell以以您喜欢的任何方式进行传输。 You could use wput, ftp, rsync, scp, etc. 您可以使用wput,ftp,rsync,scp等。

Use exec() or passthru() or system() and call system functions to transfer the files. 使用exec()passthru()system()并调用系统函数来传输文件。 rsync over SSH could be a good solution. 通过SSH进行rsync可能是一个很好的解决方案。

I would recommend using phpseclib, a pure PHP SFTP implementation . 我建议使用phpseclib,这是纯PHP SFTP实现 eg. 例如。

<?php
include('Net/SFTP.php');

$sftp = new Net_SFTP('www.domain.tld');
if (!$sftp->login('username', 'password')) {
    exit('Login Failed');
}

echo $sftp->pwd() . "\r\n";
$sftp->put('remote.file', 'local.file', NET_SFTP_LOCAL_FILE);
print_r($sftp->nlist());
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM