开发者

How do I: PHP ftp_echo

开发者 https://www.devze.com 2023-04-05 02:29 出处:网络
Variation of my question on Ubuntu.SE: This is (basically) what I\'m doing when I log into a FTP: ftp user:password@server

Variation of my question on Ubuntu.SE:

This is (basically) what I'm doing when I log into a FTP:

ftp user:password@server
ftp: user:password@server: Unknown host
ftp> echo HELLO WORLD!
ftp> quit

Is it possible to "echo" over ftp in PHP?

<?php
$ftp_server = "server";
$ftp_user_name = "user";
$ftp_user_pass = "SuperSecretPassword";
$message = "Hello World!";

// connect
$conn_id = ftp_connect($ftp_server); 

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 

// Echo Message
$upload = ft开发者_运维问答p_echo($conn_id, $message); 

// close the FTP stream 
ftp_close($conn_id); 
?>

Maybe I'm an idiot, but all the commands I see are for pushing, pulling or doing stuff locally. Does something else act as 'ftp> echo "Hello World!"' and am I'm looking right at it without realizing it?


I think you want ftp_raw. You'd use this to put an arbitrary command to your ftp server.

<?php
$fp = ftp_connect("ftp.example.com");

/* This is the same as: 
   ftp_login($fp, "joeblow", "secret"); */
ftp_raw($fp, "USER joeblow");
ftp_raw($fp, "PASS secret");
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消