安装
In order to use FTP functions with your PHP configuration, you should
add the --enable-ftp option when
installing PHP 4 or --with-ftp when using
PHP 3.
PHP 的 Windows 版本已经内置该扩展模块的支持。您无需加载任何附加的扩展库即可使用这些函数。
预定义常量
由于这些常量是由该扩展模块定义的,因此只有在该扩展模块被编译到 PHP 中,或者在运行时被动态加载后,这些常量才有效。
下列变量在 PHP 4.3.0 以后版本中被加入。
范例
例子 1. FTP 实例
<?php // set up basic connection $conn_id = ftp_connect($ftp_server);
// login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server, for user $ftp_user_name"; }
// upload the file $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status if (!$upload) { echo "FTP upload has failed!"; } else { echo "Uploaded $source_file to $ftp_server as $destination_file"; }
// close the FTP stream ftp_close($conn_id); ?>
|
|