Copy folder from a local server with php

0

Good day, I am able to copy the files contained in a folder located on a local server to my pc with the command prompt (attached image)

Could I do what I'm doing in cmd with php code?

    
asked by julian vargas 24.04.2018 в 05:36
source

1 answer

0

You could connect by FTP to a remote server and do operations on it using the functions for operations ftp here You can find more information.

Here is an example of a simple example to download a file:

<?php
// Define la conexión al servidor
$ftp_server = "ftp.ejemplo.com";
$ftp_conn = ftp_connect($ftp_server) or die("No se puede conectar al servidor $ftp_server");
//Comprueba usuario y contraseña del
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);

//Define las variables donde se almacenarán los archivos
$local_file = "local.zip";
$server_file = "server.zip";

// Descarga los archivos del servidor
if (ftp_get($ftp_conn, $local_file, $server_file, FTP_ASCII))
  {
  echo "Descargado correctamente en  $local_file.";
  }
else
  {
  echo "Error al descargar $server_file.";
  }

// Cerrar conexión
ftp_close($ftp_conn);
?> 
    
answered by 24.04.2018 в 08:41