简体   繁体   中英

PHP Copy files between servers using FTP


This question might seem like a repeat but no solution found on SO or google worked, so I restating my issue:

I have a file on server A, located in a subfolder of the root folder, eg, 'wordpress' is the subfolder, the original file is, say, 'some_file.php - is tagged with 0644 properties if that has anything to do... - and would need to have the same file copied at the root of SERVER B (using the same name for simplification...)
I understood that there might be 2 solutions:
Solution 1 is 2-fold:
1. downloading from Server A to $local_file (ftp_get...?);
2. Uploading from $local_file to Server B (ftp_put...?),

Solution 2 (?) direct ftp_put from Server A (where script is run...) to Server B

Neither seem to work for me, with the following (FTP connect & login credentials are OK, and connection tested...)
- Solution 1:
a) Download from server A:

$local_file="some_file.php";
$remote_file="wordress/some_file.php";
ftp_get( $connect_it, $local_file, $remote_file, FTP_BINARY );

b) Upload back from local folder to Server B:

$local_file="some_file.php";
$remote_file="some_file.php";
ftp_put($connect_it,$remote_file,$local_file,FTP_BINARY);

SOLUTION 2:

$local_file="wordpress/some_file.php";
$remote_file="some_file.php";
ftp_put($connect_it,$remote_file,$local_file,FTP_BINARY);

What am I not understanding / doing wrong? Many thanks for reading me through...
JMB

Hello @JMB Please follow the link its work for us and also please give file permission 664 to 777

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM