diff --git a/includes/file.inc b/includes/file.inc
index 473fbae..5710a58 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -642,31 +642,55 @@ function file_save_upload($source, $validators = array(), $dest = FALSE, $replac
     return $upload_cache[$source];
   }
 
-  // If a file was uploaded, process it.
-  if (isset($_FILES['files']) && $_FILES['files']['name'][$source] && is_uploaded_file($_FILES['files']['tmp_name'][$source])) {
-    // Check for file upload errors and return FALSE if a
-    // lower level system error occurred.
-    switch ($_FILES['files']['error'][$source]) {
-      // @see http://php.net/manual/en/features.file-upload.errors.php
-      case UPLOAD_ERR_OK:
-        break;
+  // Make sure there's an upload to process.
+  if (empty($_FILES['files']['name'][$source])) {
+    return 0;
+  }
 
-      case UPLOAD_ERR_INI_SIZE:
-      case UPLOAD_ERR_FORM_SIZE:
-        drupal_set_message(t('The file %file could not be saved, because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $source, '%maxsize' => format_size(file_upload_max_size()))), 'error');
-        return 0;
+  // Handling of upload error set on the $_FILES variable that comes from PHP.
+  switch ($_FILES['files']['error'][$source]) {
+    case UPLOAD_ERR_INI_SIZE:
+    case UPLOAD_ERR_FORM_SIZE:
+      drupal_set_message(t('The file %file could not be saved, because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $_FILES['files']['name'][$source], '%maxsize' => format_size(file_upload_max_size()))), 'error');
+      return 0;
 
-      case UPLOAD_ERR_PARTIAL:
-      case UPLOAD_ERR_NO_FILE:
-        drupal_set_message(t('The file %file could not be saved, because the upload did not complete.', array('%file' => $source)), 'error');
-        return 0;
+    case UPLOAD_ERR_PARTIAL:
+    case UPLOAD_ERR_NO_FILE:
+      drupal_set_message(t('The file %file could not be saved, because the upload did not complete.', array('%file' => $_FILES['files']['name'][$source])), 'error');
+      return 0;
 
-        // Unknown error
-      default:
-        drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $source)), 'error');
-        return 0;
-    }
+    case UPLOAD_ERR_NO_TMP_DIR:
+      drupal_set_message(t('Missing a temporary folder', array(), 'error');
+      return 0;
+
+    case UPLOAD_ERR_CANT_WRITE:
+      drupal_set_message(t('Failed to write file to disk'), array(), 'error');
+      return 0;
 
+    case UPLOAD_ERR_EXTENSION:
+      drupal_set_message(t('A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop'), array(), 'error');
+      return 0;
+
+    case UPLOAD_ERR_OK:
+      // Final check that this is a valid upload, if it isn't, use the
+      // default error handler.
+      if (is_uploaded_file($_FILES['files']['tmp_name'][$source])) {
+        break;
+      }
+
+    // Unknown error
+    default:
+      drupal_set_message(t('The file %file could not be saved. An unknown error has occurred. Error number : %err',
+        array(
+          '%file' => $_FILES['files']['name'][$source],
+          '%err' => $_FILES['files']['error'][$source]
+          )
+        ), 'error');
+      return 0;
+  }
+
+  // If a file was uploaded, process it.
+  if (isset($_FILES['files']) && $_FILES['files']['name'][$source] && is_uploaded_file($_FILES['files']['tmp_name'][$source])) {
     // Build the list of non-munged extensions.
     // @todo: this should not be here. we need to figure out the right place.
     $extensions = '';
