function drupal_ftp_ftp_to_file in Backup and Migrate 6.3
Same name and namespace in other branches
- 8.2 includes/destinations.ftp.inc \drupal_ftp_ftp_to_file()
- 8.3 includes/destinations.ftp.inc \drupal_ftp_ftp_to_file()
- 6.2 includes/destinations.ftp.inc \drupal_ftp_ftp_to_file()
- 7.3 includes/destinations.ftp.inc \drupal_ftp_ftp_to_file()
- 7.2 includes/destinations.ftp.inc \drupal_ftp_ftp_to_file()
This function tries to retrieve the contents of a file from the FTP server. Firstly it changes into the $directory directory, and then attempts to download the file $filename. The file is saved locally and its contents are returned to the caller of the function.
1 call to drupal_ftp_ftp_to_file()
- backup_migrate_destination_ftp::load_file in includes/
destinations.ftp.inc - Load from the ftp destination.
File
- includes/
destinations.ftp.inc, line 203 - Functions to handle the FTP backup destination.
Code
function drupal_ftp_ftp_to_file($file, $filename, $directory, &$ftp) {
// Change into the remote directory and retrieve the content
// of a file. Once retrieve, return this value to the caller
if (!@drupal_ftp_connect($ftp)) {
return FALSE;
}
// We are now connected, so let's retrieve the file contents.
// Firstly, we change into the directory
$chdir = @ftp_chdir($ftp->__conn, $directory);
if (!$chdir) {
_backup_migrate_message('FTP Error: Couldn\'t change into directory: @directory', array(
'@directory' => $directory,
), 'error');
return FALSE;
}
// We have changed into the directory, let's attempt to get the file
$fp = @fopen($file, 'wb');
$get_file = @ftp_fget($ftp->__conn, $fp, $filename, FTP_BINARY);
fclose($fp);
$fp = NULL;
if (!$get_file) {
_backup_migrate_message('FTP Error: Unable to download file: @filename from @directory', array(
'@filename' => $filename,
'@directory' => $directory,
), 'error');
return FALSE;
}
return TRUE;
}