WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

PHP ftp_exec () function


Definition and usage

The ftp_exec () function requests that a program or command be executed on the FTP server.

If successful, the function returns TRUE. If it fails, it returns FALSE.

Syntax

ftp_exec (ftp_connection, command)

parameters description
ftp_connection Required. Specifies the FTP connection to use.
command Required. Specifies the command request sent to the FTP server.


Tips and comments

Note: Unlike the ftp_raw () function, ftp_exec () can send commands only after logging into the FTP server.


Example

<?php
$command = "ls-al > test.txt";
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");

if (ftp_exec($conn,$command))
{
echo "Command executed successfully";
}
else
{
echo "Execution of command failed";
}

ftp_close($conn);
?>