PHP.mk документација

ftp_rename

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.ftp-rename.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.ftp-rename.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
ftp_rename

Референца за `function.ftp-rename.php` со подобрена типографија и навигација.

function.ftp-rename.php

ftp_rename

(PHP 4, PHP 5, PHP 7, PHP 8)

ftp_renameПреименува датотека или директориум на FTP-серверот

= NULL

ftp_rename(FTP\Connection $ftp, string $from, string $to): bool

ftp_rename() преименува датотека или директориум на FTP-серверот.

Параметри

ftp

Еден FTP\Connection instance.

from

Старото име на датотеката/директориумот.

to

одговара на обвивката што се користи во

Вратени вредности

Патеката до PHP скриптата што треба да се провери. true на успех или false при неуспех. При неуспех (како обид за преименување на непостоечка датотека), ќе се емитува E_WARNING грешка.

Дневник на промени

Верзија = NULL
8.1.0 На ftp параметарот очекува FTP\Connection инстанца сега; претходно, а resource се очекуваше.

Примери

Пример #1 ftp_rename() example

<?php
$old_file
= 'somefile.txt.bak';
$new_file = 'somefile.txt';

// Set up basic connection
$ftp = ftp_connect($ftp_server);

// Login with username and password
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);

// Try to rename $old_file to $new_file
if (ftp_rename($ftp, $old_file, $new_file)) {
echo
"Successfully renamed $old_file to $new_file\n";
} else {
echo
"There was a problem while renaming $old_file to $new_file\n";
}

// Close the connection
ftp_close($ftp);

?>

Белешки од корисници 4 белешки

Hugo locobyte на hotmail dot NO_SPAM dot com
пред 23 години
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
alishahnovin на hotmail точка com
пред 18 години
You want to make sure you check the existence of the new name before renaming files, because otherwise you could risk losing files. Just do a simple check with ftp_size with the new name. If it's !=-1, you're going to want to throw some kind of error, otherwise you'll be losing a file...
Hazem dot Khaled на gmail dot com
19 години пред
to rename the file or folder you should use ftp_chdir to select the current directory on ftp server or you should write the full path to file in old name and in new name

Ex. 1
<?php
// open the folder that have the file
ftp_chdir($conn_id, '/www/ftp-filemanager/');

// rename the file
ftp_rename($conn_id, 'file1.jpg', 'new_name_4_file.jpg');
?>

or write full path Ex. 2
<?
// rename the file
ftp_rename($conn_id, '/www/ftp-filemanager/file1.jpg', '/www/ftp-filemanager/new_name_4_file.jpg');
?>
aventaria на hotmxxx dot com
19 години пред
This function isn't only able to rename files, but also folders. And it is not only able to rename them, but also move them, and, in the case of folders, their contents as well (so folders don't have to be empty to move). For example:

<?php
ftp_rename($conn_id, "./dir1/dir2/", "./dir3/");
?>

Now the folder dir2 (which prevously was in folder dir1) has moved to the same folder as dir1, and it has kept its original contents (the content just moved along).
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.