ftp_rename

(PHP 3 >= 3.0.13, PHP 4, PHP 5)

ftp_rename -- 更改 FTP 服务器上指定的文件名

描述

bool ftp_rename ( resource ftp_stream, string from, string to )

ftp_rename() 用来把参数 from 指定的文件或目录更名为 to 参数,使用的连接句柄为参数 ftp_stream

如果成功则返回 TRUE,失败则返回 FALSE


add a note add a note User Contributed Notes
Hugo locobyte at hotmail dot NO_SPAM dot com
23-Nov-2002 04:29
Using "ftp_rename" to move files to other directories on server ftp
..
...
if(ftp_rename($conn_ftp, $xfiles[$i], "./dirx/".$xfiles[$i])) {
       echo "File $xfiles[$i] moved to ./dirx";
} else {
       echo "ERROR!!!. The file could not be moved";
}
...
..
#-->>h2m,  bye
29-Sep-2000 07:59
# Simple example for ftp_rename
# Warning! Not tested...

$server = 'ftp.somewhere.com';

$user = 'anonymous';
$pass = 'someone@somewhere.com';

$original_name = 'file_name.txt';
$new_name = 'new_file_name.txt';

$ftp_connect = ftp_connect ($server)
   or die ("Could not connect to $server");

$ftp = ftp_login ($ftp_connect, $user, $pass)
   or die ("Authentication failed");

$rename = ftp_rename ($ftp_connect, $original_name, $new_name);

if ($rename)
   print "$original_name renamed to $new_name.";
else
   print "$original_name could not be renamed...";

ftp_quit ($ftp_connect);