主要取决于您可以使用什么。
您可以使用安全的 SFTP 来做到这一点:
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
ssh2_scp_send($connection, '/local/filename', '/remote/filename', 0644);
PHP手册在这里:function.ssh2-scp-send.php
或不安全的 FTP:
$file = 'somefile.txt';
$remote_file = 'readme.txt';
// set up basic connection
$conn_id = ftp_connect("ftp.example.com");
// login with username and password
$login_result = ftp_login($conn_id, "username", "password");
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
// close the connection
ftp_close($conn_id);
PHP手册在这里:function.ftp-put.php
或者您可以使用 PHP 发送 HTTP 请求:
这更像是另一台服务器看到的真实 Web 浏览器行为:
You can use socket_connect();
and socket_write();
, I will add more information about those later.