diff --git a/includes/file.inc b/includes/file.inc index bb9a6a5942358cc48f1cd11de9179e928dc12d4f..6cf3586df89051acd4e81de3fea6fb0d4d8b352c 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