? files
? sites/all/modules
? sites/default/settings.php
Index: includes/file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.104
diff -u -p -r1.104 file.inc
--- includes/file.inc	25 Jul 2007 17:41:27 -0000	1.104
+++ includes/file.inc	5 Sep 2007 21:04:07 -0000
@@ -491,17 +491,17 @@ function file_save_upload($source, $vali
   }
 
   // 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.
+  if (isset($_FILES['files']) && $_FILES['files']['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;
-
       case UPLOAD_ERR_INI_SIZE:
+        drupal_set_message(t("The file %file could not be saved, because it exceeds %maxsize, PHP's maximum allowed size for uploads.", array('%file' => $source, '%maxsize' => format_size(parse_size(ini_get('upload_max_filesize'))))), 'error');
+        return 0;
+
       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');
+        drupal_set_message(t('The file %file because it exceeds the maximum size allowed for uploads.', array('%file' => $source, '%maxsize' => format_size(parse_size(ini_get('upload_max_filesize'))))), 'error');
         return 0;
 
       case UPLOAD_ERR_PARTIAL:
@@ -509,7 +509,14 @@ function file_save_upload($source, $vali
         drupal_set_message(t('The file %file could not be saved, because the upload did not complete.', array('%file' => $source)), 'error');
         return 0;
 
-        // Unknown error
+      case UPLOAD_ERR_OK:
+        // Final check that this is a valid upload, if isn't fall through to
+        // 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.', array('%file' => $source)), 'error');
         return 0;
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.180
diff -u -p -r1.180 upload.module
--- modules/upload/upload.module	5 Sep 2007 18:09:49 -0000	1.180
+++ modules/upload/upload.module	5 Sep 2007 21:04:09 -0000
@@ -533,7 +533,10 @@ function theme_upload_form_new($form) {
 function upload_load($node) {
   $files = array();
 
-  if ($node->vid) {
+	if (!isset($node->vid) && !isset($node->nid)) {
+	 	drupal_set_message(t('Upload size is too big for POST.'), 'error');
+	}
+	elseif ($node->vid) {
     $result = db_query('SELECT * FROM {files} f INNER JOIN {upload} r ON f.fid = r.fid WHERE r.vid = %d ORDER BY f.fid', $node->vid);
     while ($file = db_fetch_object($result)) {
       $files[$file->fid] = $file;
