diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-07-07 08:59:07 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-07-07 08:59:07 +0000 |
commit | a86654f876bf7d3ff4cd7aa1dbe858d18d384f79 (patch) | |
tree | d59bfb88874ea349f5a5311f8ed97b3dca8773b4 | |
parent | d6ce954260c32a1ac21f006159178cfb67afef8d (diff) | |
download | brdo-a86654f876bf7d3ff4cd7aa1dbe858d18d384f79.tar.gz brdo-a86654f876bf7d3ff4cd7aa1dbe858d18d384f79.tar.bz2 |
- Patch #511760 by rfay: improve the error messages in file_unmanaged_copy().
-rw-r--r-- | includes/file.inc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/includes/file.inc b/includes/file.inc index bb9a6a594..6cf3586df 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -445,19 +445,22 @@ function file_copy($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) * @see file_copy() */ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) { + $original_source = $source; + $original_destination = $destination; + $source = realpath($source); if (!file_exists($source)) { - drupal_set_message(t('The specified file %file could not be copied, because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $source)), 'error'); + drupal_set_message(t('The specified file %file could not be copied, because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error'); return FALSE; } - $destination = file_create_path($destination); - $directory = $destination; + $proposed_destination = file_create_path($destination); + $directory = $proposed_destination; $basename = file_check_path($directory); // Make sure we at least have a valid directory. if ($basename === FALSE) { - drupal_set_message(t('The specified file %file could not be copied, because the destination %directory is not properly configured.', array('%file' => $source, '%directory' => $destination)), 'error'); + drupal_set_message(t('The specified file %file could not be copied, because the destination %directory is not properly configured. This is often caused by a problem with file or directory permissions.', array('%file' => $original_source, '%directory' => empty($original_destination) ? $proposed_destination : $original_destination)), 'error'); return FALSE; } @@ -467,7 +470,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST $destination = file_destination($directory . '/' . $basename, $replace); if ($destination === FALSE) { - drupal_set_message(t('The specified file %file could not be copied because a file by that name already exists in the destination.', array('%file' => $source)), 'error'); + drupal_set_message(t('The specified file %file could not be copied because a file by that name already exists in the destination %directory.', array('%file' => $source, '%directory' => $proposed_destination)), 'error'); return FALSE; } // Make sure source and destination filenames are not the same, makes no |