*** file.inc.orig	Sat Aug  5 14:34:33 2006
--- file.inc	Sat Aug  5 15:35:59 2006
***************
*** 191,222 ****
      return $upload_cache[$source];
    }
  
    // If a file was uploaded, process it.
    if ($_FILES["edit"]["name"][$source] && is_uploaded_file($_FILES["edit"]["tmp_name"][$source])) {
- 
-     // Check for file upload errors and return false if a
-     // lower level system error occurred.
-     switch ($_FILES["edit"]["error"][$source]) {
- 
-       // @see http://php.net/manual/en/features.file-upload.errors.php
-       case UPLOAD_ERR_OK:
-         break;
- 
-       case UPLOAD_ERR_INI_SIZE:
-       case UPLOAD_ERR_FORM_SIZE:
-         drupal_set_message(t('The file %file could not be saved, because it exceeds the maximum allowed size for uploads.', array('%file' => theme('placeholder', $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' => theme('placeholder', $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' => theme('placeholder', $source))),'error');
-         return 0;
-     }
  
      // Begin building file object.
      $file = new StdClass();
--- 191,233 ----
      return $upload_cache[$source];
    }
  
+   // Check for file upload errors and return false if a
+   // lower level system error occurred.
+   switch ($_FILES["edit"]["error"][$source]) {
+ 
+     // @see http://php.net/manual/en/features.file-upload.errors.php
+     case UPLOAD_ERR_OK:
+       break;
+ 
+     case UPLOAD_ERR_INI_SIZE:
+     case UPLOAD_ERR_FORM_SIZE:
+       drupal_set_message(t('The file %file could not be saved, because it exceeds the maximum allowed size for uploads.', array('%file' => theme('placeholder', $source))), 'error');
+       return false;
+ 
+     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' => theme('placeholder', $source))), 'error');
+       return false;
+ 
+     case UPLOAD_ERR_NO_TMP_DIR:
+       drupal_set_message(t('The file %file could not be saved because no tmp folder was specified in php.ini', array('%file' => theme('placeholder', $source))), 'error');
+       watchdog('php', t('The selected file %file could not not be uploaded because upload_tmp_dir was not set in php.ini.', array('%file' => theme('placeholder', $source), )), WATCHDOG_ERROR);
+ 
+       return false;
+ 
+     case UPLOAD_ERR_CANT_WRITE:
+       drupal_set_message(t('The file %file could not be saved: write error', array('%file' => theme('placeholder', $source))), 'error');
+       watchdog('file system', t('The selected file %file could not be uploaded because the destination directory could not be found, or because its permissions do not allow the file to be written, or because a write error occured.', array('%file' => theme('placeholder', $source))), WATCHDOG_ERROR);
+       return false;
+ 
+     // Unknown error
+     default:
+       drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => theme('placeholder', $source))),'error');
+       return false;
+   }
+ 
    // If a file was uploaded, process it.
    if ($_FILES["edit"]["name"][$source] && is_uploaded_file($_FILES["edit"]["tmp_name"][$source])) {
  
      // Begin building file object.
      $file = new StdClass();
