Answer the question
In order to leave comments, you need to log in
How to move directory and attached files to another directory on ftp server via ftp_rename?
How to move directory and attached files to another directory on ftp server via ftp_rename?
I try to do as described in the manual, but it does not work. Tell me what I'm doing wrong.
$old_path="2014/$company/$id/";
$new_path=".trash/$company/$id/";
$ftp_server = "xx.xxx.xxx.xxx";
$ftp_user_name = "xxx_xxxxx";
$ftp_user_pass = "xxxxxxxx";
$conn_id = ftp_connect($ftp_server,21);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (ftp_rename($conn_id, $old_path, $new_path)) {
echo "Файлы $old_path перемещены в $new_path\n";
} else {
echo "Не удалось переместить $old_path в $new_path\n";
}
Answer the question
In order to leave comments, you need to log in
everything is correct (almost)
the only nuance in which you need to "dig" is the correct location of $old_path and $new_path
according to the described code, it should be so that 2014 and .trash should be in the same location ZY
. while writing - another thought came that .trash/$company might not be automatically created. therefore, it is better to first check (and create, if necessary) the folder (s), and only then move
yes, by the way, the last / is not needed in the paths
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question