Skip to main content
improved formatting
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

UYou can connect to the server through ftp from codeusing the FTP protocol, and download itthe file to your server or local and you can show it  .

function example_download_image() {
      $local_file = 'tmp/download.jpg';
      $server_file = 'tmp_server/download.jpg';
      $ftp_server = "ftp.server.com";
      $conn_id = ftp_connect($ftp_server);
      $ftp_user_name = "user_name";
      $ftp_user_pass = "password";
      $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
      ftp_pasv($conn_id, true);
      if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
     // }
Show the file.
  }
  else {
        drupal_set_message("There was a problem\n");
      }
      ftp_close($conn_id);
    }

U can connect to server through ftp from code and download it to your server or local and you can show it  .

function example_download_image() {
      $local_file = 'tmp/download.jpg';
      $server_file = 'tmp_server/download.jpg';
      $ftp_server = "ftp.server.com";
      $conn_id = ftp_connect($ftp_server);
      $ftp_user_name = "user_name";
      $ftp_user_pass = "password";
      $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
      ftp_pasv($conn_id, true);
      if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
      }
      else {
        drupal_set_message("There was a problem\n");
      }
      ftp_close($conn_id);
    }

You can connect to the server using the FTP protocol, and download the file to show it.

function example_download_image() {
  $local_file = 'tmp/download.jpg';
  $server_file = 'tmp_server/download.jpg';
  $ftp_server = "ftp.server.com";
  $conn_id = ftp_connect($ftp_server);
  $ftp_user_name = "user_name";
  $ftp_user_pass = "password";
  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  ftp_pasv($conn_id, true);
  if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
    // Show the file.
  }
  else {
    drupal_set_message("There was a problem\n");
  }
  ftp_close($conn_id);
}
Source Link
Shreya Shetty
  • 2.9k
  • 14
  • 28

U can connect to server through ftp from code and download it to your server or local and you can show it .

function example_download_image() {
      $local_file = 'tmp/download.jpg';
      $server_file = 'tmp_server/download.jpg';
      $ftp_server = "ftp.server.com";
      $conn_id = ftp_connect($ftp_server);
      $ftp_user_name = "user_name";
      $ftp_user_pass = "password";
      $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
      ftp_pasv($conn_id, true);
      if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
      }
      else {
        drupal_set_message("There was a problem\n");
      }
      ftp_close($conn_id);
    }