file_destination

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 file_destination($destination, $replace)

Determines the destination path for a file depending on how replacement of existing files should be handled.

Übergabeparameter

$destination A string specifying the desired path.

$replace Replace behavior when the destination file already exists.

Rückgabewert

The destination file path or FALSE if the file already exists and FILE_EXISTS_ERROR was specified.

Verwandte Themen

▾ 2 functions call file_destination()

file_copy in includes/file.inc
Copies a file to a new location.
file_save_upload in includes/file.inc
Saves a file upload to a new location.

Code

includes/file.inc, line 303

<?php
function file_destination($destination, $replace) {
  if (file_exists($destination)) {
    switch ($replace) {
      case FILE_EXISTS_RENAME:
        $basename = basename($destination);
        $directory = dirname($destination);
        $destination = file_create_filename($basename, $directory);
        break;

      case FILE_EXISTS_ERROR:
        drupal_set_message(t('The selected file %file could not be copied, because a file by that name already exists in the destination.', array('%file' => $destination)), 'error');
        return FALSE;
    }
  }
  return $destination;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen