Hàm ftp_exec() thực thi một lệnh trên máy chủ FTP.
Cú pháp
ftp_exec($conn, $command)
Tham số
conn – Kết nối FTP.
command – Lệnh cần thực thi.
Giá trị trả về
Hàm trả về TRUE nếu lệnh thực thi thành công, FALSE nếu không.
Ví dụ
<?php
$ftp_server = "192.168.0.4";
$ftp_user = "amit";
$ftp_pass = "tywg61gh";
$con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$command = 'ls';
if (ftp_exec($con, $command)) {
echo "Executed successfully!";
} else {
echo "Execution failed!";
}
ftp_close($con);
?>