From a86654f876bf7d3ff4cd7aa1dbe858d18d384f79 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 7 Jul 2009 08:59:07 +0000 Subject: - Patch #511760 by rfay: improve the error messages in file_unmanaged_copy(). --- includes/file.inc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'includes') 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 -- cgit v1.2.3