PHP ftp_exec()関数
例
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_conn, command);
パラメータ値
Parameter | Description |
---|---|
ftp_conn | Required. Specifies the FTP connection to use |
command | Required. Specifies the command to execute |
技術的な詳細
戻り値: | コマンドが正常に実行された場合はTRUE。それ以外の場合はFALSE |
---|---|
PHPバージョン: | 4.0.3+ |
❮PHPFTPリファレンス