The destination FTP folder has 775 permissions, and the FTP user is the administrator user of that shared hosting account and therefore I understand that the permissions when making the transfer are adequate to be able to write.
The code includes a function that recursively copies the entire folder structure, with subfolders, etc... and this is true, that is, the folder structure is generated, therefore it makes me doubt that the problem is permissions. but the files are never copied.
The code is simple, but it always gives error:
$ftphost = "ftp.destino.com";
$ftpuser = "usuario-ftp";
$ftppass = "pass-ftp";
$conexion = ftp_connect($ftphost);
$ftplogin = ftp_login($conexion, $ftpuser, $ftppass) or die ("Error FTP login");
$origen = "/ftp.php"; //Esto genera la ruta /home/xxxxx/web/dominio/test/ftp.php
//Comprobado que en destino la ruta actual es la que debe ser.
$destino = "/ftp.movido.php";
if(ftp_put($conexion, $destino, $origen, FTP_BINARY))
echo "OK";
else
echo "ERROR. <br>origen: $origen<br>destino: $destino";
if(ftp_close($conexion))
echo "<br><br>OK: Conexión FTP cerrada<br>";
else
"<br><br>ERROR: No se ha podido cerrar la conexión FTP<br>";
Note: To test I have also tried with FTP_ASCII mode but the result is the same.
Fixed.
The problem came because after doing the ftp_login() you have to tell the connection the transfer mode, in this case PASV. So the problem has been solved by adding
right after the ftp_login.
I leave you these two scripts that I had in my code library :).
One is for importing, the other for exporting. As is logical, the one to import must be used from the shared hosting, the one to export must be executed from the VPS server.
Either one should work just fine. Change whatever is needed: file names, usernames, passwords, etc.
to import
Export