You are here

function drupal_ftp_create_directory in Backup and Migrate 8.2

Same name and namespace in other branches
  1. 8.3 includes/destinations.ftp.inc \drupal_ftp_create_directory()
  2. 6.3 includes/destinations.ftp.inc \drupal_ftp_create_directory()
  3. 6.2 includes/destinations.ftp.inc \drupal_ftp_create_directory()
  4. 7.3 includes/destinations.ftp.inc \drupal_ftp_create_directory()
  5. 7.2 includes/destinations.ftp.inc \drupal_ftp_create_directory()

The drupal_ftp_create_directory Function This function tries to make a new directory called $folder_name on the FTP server. If it can create the folder, then the folder is given appropriate rights with the CHMOD command.

File

includes/destinations.ftp.inc, line 329
Functions to handle the FTP backup destination.

Code

function drupal_ftp_create_directory($folder_name, &$ftp) {

  // Makes a new folder on the web server via FTP
  if (!@drupal_ftp_connect($ftp)) {
    return FALSE;
  }
  $create_result = @ftp_mkdir($ftp->__conn, $folder_name);
  if ($create_result == TRUE) {

    // Can we change the files permissions?
    $exec_result = @ftp_site($ftp->__conn, 'chmod 0777 ' . $folder_name . '/');
    if ($exec_result == TRUE) {
      return TRUE;
    }
    else {
      _backup_migrate_message('FTP Error: Couldn\'t set owner permissions on @folder.', array(
        '@folder',
        $folder_name,
      ), 'error');
      return FALSE;
    }
  }
  else {
    _backup_migrate_message('FTP Error: Couldn\'t create new folder @folder.', array(
      '@folder',
      $folder_name,
    ), 'error');
    return FALSE;
  }
}