I think there's a problem in upload.module, around here:

$maxsize = variable_get("upload_maxsize_total", 0);
        $total_size = upload_count_size() + $filesize;
        $total_usersize = upload_count_size($user->uid) + $filesize;

        if ($maxsize && $total_size > $maxsize) {
          form_set_error('upload', t('Error attaching file %name: total file size exceeded', array('%name' => theme('placeholder', $file->filename))));
          break;
        }

If upload_maxsize_total is the default (0, unlimited) then we have no problems. However, if we follow instructions on the upload settings page, and change this to, say, 1 megabyte, the comparison:

$total_size > $maxsize

will (almost always!) fail, as we're comparing the file size in bytes to a value we are told to input in megabytes.

Comments

David Hull’s picture

Yes, I noticed the same problem. Here's my fix:

--- upload.module.orig	Mon Apr 25 22:14:35 2005
+++ upload.module	Mon Apr 25 22:39:32 2005
@@ -164,7 +164,7 @@ function upload_nodeapi(&$node, $op, $ar
 
         $file = _upload_image($file);
 
-        $maxsize = variable_get("upload_maxsize_total", 0);
+        $maxsize = variable_get("upload_maxsize_total", 0) * 1024 * 1024;
         $total_size = upload_count_size() + $filesize;
         $total_usersize = upload_count_size($user->uid) + $filesize;
pfaocle’s picture

Thats what I did, but I didn't submit a patch as it may not be the nicest solution. The upload settings should probably remain in Mb (or perhaps Kb?). Any thoughts from the maintainers?

pfaocle’s picture

Version: 4.6.0 »

Bumping - still applies in HEAD.

Steven’s picture

Committed to 4.6 and HEAD.

Anonymous’s picture

iraszl’s picture

Version: » 4.6.0
Category: bug » support

I've tried to download the cvs 1.39 version of the upload.module with the fixed "upload size". Replaced the upload.module, but it still not works. Also, when I try to check the upload settings, nothing loads. Looks like the module is broken on my system. Is there anything I need to know as how to replace the original 4.6.0 upload module with this cvs version?

Reference:
http://cvs.drupal.org/viewcvs/drupal/drupal/modules/upload.module?rev=1....

Steven’s picture

The most important thing: modules do not work across major Drupal releases. HEAD has already had significant changes which break 4.6 modules;