Forums | Mahara Community

Support /
Upload fails with UPLOAD_ERR_FORM_SIZE


anonymous profile picture
Account deleted
Posts: 6

27 February 2014, 3:11

I am running Mahara 1.8.1 on x86_64 Debian  7.0 with Apache 2.2.22, PHP 5.4.4 and MySQL 5.5.35.

upload_max_filesize is set to 5000M

post_max_size is set to 5000M

(I verified this with a phpinfo(); from the mahara directory)

When uploading a file with the embedded media block the upload fails with UPLOAD_ERR_FORM_SIZE (well, the error message is "The file was too big. Please ask your administrator for more information.", but I made lib/uploadmanager.php return the error code, which is UPLOAD_ERR_FORM_SIZE).

I have no idea where and how the form size is set. I looked at artefact/file/theme/raw/form/filebrowser.tpl and MAX_FILE_SIZE is set to $phpmaxfilesize which in turn is 5242880000 so I don't see how it could fail.

The file itself is 2,4GB so it shouldn't really be a problem.

If anyone has any pointers on what I could be missing here I'd really appreciate it :)

27 February 2014, 4:06

Hello,

Have your checked the parameters in your File's artefact plugin. You can find information about this in the user manual: http://manual.mahara.org/en/1.8/administration/extensions.html; under "9.6.1.5. Artefact type: File".

-dajan

anonymous profile picture
Account deleted
Posts: 6

04 March 2014, 22:58

Yeah, I did. The linked PDF file shows all my file extension settings (sorry about the german locale).

http://user.phil-fak.uni-duesseldorf.de/~pranaitis/mahara1.pdf

A post by Account deleted was deleted

Aaron Wells's profile picture
Posts: 896

05 March 2014, 12:32

That is strange. The error UPLOAD_ERR_FORM_SIZE is supposed to indicate that the file uploaded is larger than the value of the MAX_FILE_SIZE directive that was sent as part of the HTTP request (due to it being in a hidden form field).

I'd recommend this:

1. If you haven't already, look at the HTML source of the generated page to verify for sure what the final value of the "MAX_FILE_SIZE" hidden form field is.

2. Since you're already experimenting with modifying the PHP files, just eliminate the MAX_FILE_SIZE form field, and then see if it works.

Cheers,

Aaron

anonymous profile picture
Account deleted
Posts: 6

05 March 2014, 22:56

Good idea!

I checked the MAX_FILE_SIZE and it's set to "5242875904". So I don't think that would be a problem. However removing the hidden form field allowed the upload to succeed (the "upload spinner" continued to turn, but after waiting a substantial amount of time and reloading the page the file was there and had the same md5sum).

So as a workaround commenting that hidden field is fine for now, but a more elegant solution that doesn't eliminate the "successful upload" message is still needed.

Aaron Wells's profile picture
Posts: 896

06 March 2014, 11:00

Hm, so your MAX_FILE_SIZE was large enough, but it still errored out. That sounds like a bug in PHP. Are you on a 32-bit system? The largest signed integer in 32-bit PHP is roughly 2 billion, and your MAX_FILE_SIZE is roughly 5 billion, so perhaps that could be the cause of the problem.

Regardless, after readnig up on the subject in appears that MAX_FILE_SIZE is unnecessary anyway. It's supposed to be provided so that the web browser can read it from the form and prevent the upload on the client side. But in practice, no current web browser actually does this. Which makes MAX_FILE_SIZE redundant, because we already use other means to enforce the size limit after the file has been uploaded.

Which leads me to think that maybe we should just remove the MAX_FILE_SIZE parameter altogether.

anonymous profile picture
Account deleted
Posts: 6

11 March 2014, 23:24

No, I'm runnnig a 64bit system, I also suspected some problem with 32bit integers, but PHP_INT_MAX is 9223372036854775807 and PHP_INT_SIZE is 8.

If MAX_FILE_SIZE is redundant removing it sounds like a good idea.

anonymous profile picture
Account deleted
Posts: 2

21 March 2014, 12:06

I experienced the same problem as Jens and Aaron's workaround of removing MAX_FILE_SIZE hidden form field worked for me too. Thank you for the info. 

Specifically, I edited /artefact/file/theme/raw/form/filebrowser.tpl. In my case though, the usual "successful upload" message is not lost.

My Mahara instance is on a system similar to Jens' (Mahara 1.8.1 on x86_64 Debian 7.4 with Apache 2.2.22, PHP 5.4.4 and MySQL 5.5.35) and I test with Google Chrome on OS X. It was installed at 1.6 and the issue emerged at upgrade to 1.7 or 1.8.

anonymous profile picture
Account deleted
Posts: 2

18 April 2015, 22:32

In Mahara 15.04, the element

<input type="hidden" name="MAX_FILE_SIZE" value="{$phpmaxfilesize}" />

has been move to 

  • Line 45, htdocs/theme/raw/artefact/file/templates/form/filebrowser.tpl
10 results