ฟังก์ชัน ftp_exec() ใช้เพื่อดำเนินการคำสั่งบนเซิร์ฟเวอร์ FTP
ไวยากรณ์
ftp_exec(con, command)
พารามิเตอร์
-
เสีย - การเชื่อมต่อ FTP
-
คำสั่ง − คำสั่งให้ดำเนินการ
คืนสินค้า
ฟังก์ชัน ftp_exec() จะคืนค่า TRUE หากดำเนินการคำสั่งสำเร็จ มิฉะนั้น FALSE
ตัวอย่าง
ต่อไปนี้เป็นตัวอย่างที่รันคำสั่งบนเซิร์ฟเวอร์ FTP -
<?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");
// list all the files of the remote directory
$command = 'ls';
// execute command
if (ftp_exec($con,$command)) {
echo "Executed successfully!";
} else {
echo "Execution failed!";
}
ftp_close($con);
?>