FTPサーバ上でコマンドの実行を要求します:
<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
$command = "ls-al > somefile.txt";
// execute command
if (ftp_exec($ftp_conn,$command))
{
echo "$command executed successfully.";
}
else
{
echo "Execution of $command failed.";
}
// close connection
ftp_close($ftp_conn);
?>
ftp_exec() 関数は、FTPサーバ上でコマンドの実行を要求します。
ftp_exec(ftp_connection,command);
パラメータ | 説明 |
---|---|
ftp_connection | 必須。 使用するFTP接続を指定する |
command | 必須。実行するコマンドを指定する |
返り値: | コマンドが正常に実行された場合はTRUEを返し、そうでない場合はFALSEを返します |
---|---|
PHP バージョン: | 4.0.3+ |