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);
?>