Upload Limit - Does not work

Upload Limit - Does not work

by Stephen Parker -
Number of replies: 13

Hello everyone.  I have installed moodle and everything works well. 

I am using version 2.9.1

However, currently my upload limit is set to 2M and I am unable to increase it.  Currently my PHP shows that I should be able to upload up to 128M however when I go to 'Security' - 'Site Policy' I can only select 'Site Limit 2M'.  Is there another place I can increase the site limit?

Thank you for your help.


Stephen Parker.

Average of ratings: -
In reply to Stephen Parker

Re: Upload Limit - Does not work

by Usman Asar -
Picture of Plugin developers Picture of Testers

Stephen, there are actually 2 parameters you'll be looking at determining the php upload limit

Maximum allowed size for uploaded files.

upload_max_filesize = XXM

and

post_max_size = XXM  (this value is ideally kept slightly greater than previous one), your limit for upload showing 128M must be this one, and not upload max file size.

In reply to Stephen Parker

Re: Upload Limit - Does not work

by Joseph Formoso -

I'm having a similar problem; I've set the upload_max_filesize and the post_max_size in php.ini, restarted Apache, and see the new limit in the Moodle system settings.  I've set the limits to 25000M (25GB), as some of the file backups that we need to upload are that big.  However, when trying to upload a relatively small backup file (2.4GB in size), I get the "Uploaded file exceeded the maximum size limit set by the form" error.  What's especially maddening is that I haven't touched the configuration, and our Moodle admin has uploaded very large files before with no issue.

Is there anywhere I can check to see where the hangup is, or any other settings (in Moodle, in PHP, in Apache, or wherever) that I can investigate?  Any pointers greatly appreciated.

In reply to Joseph Formoso

Re: Upload Limit - Does not work

by Usman Asar -
Picture of Plugin developers Picture of Testers

Joseph,

in your case I would as well take into consideration, the memory_limit parameter, also as  I mentioned above, keeping post_max_size value larger than upload_max_size, and keeping memory_limit equal to post_max_size, if still it shows issues, then try increasing value of memory_limit more than what you have assigned  to post_max_size.

In reply to Usman Asar

Re: Upload Limit - Does not work

by Joseph Formoso -

I'll try increasing the memory, and see if that helps.  However, in the past, we've uploaded much larger files than the one I'm trying to upload now, with no issues.  We've certainly uploaded files that are over 2GB in size, which is how much memory this server has.

In reply to Usman Asar

Re: Upload Limit - Does not work

by Joseph Formoso -

I increased the memory_limit to 1024M (half of available system memory), with the same results.  The file *is* larger than this, but we've uploaded files far in excess of memory_limit in the past (the largest, according to our Moodle user, was around 20GB).  I've made sure logging is on for PHP, but there's nothing produced.  Checking for site errors in the Moodle admin GUI, similarly, turns up nothing.

Any suggestions -- even long shots -- are welcome.  It's really maddening to have something that used to work start producing mysterious behavior.

In reply to Joseph Formoso

Re: Upload Limit - Does not work

by ben reynolds -

You didn't say what OS you are using. If Windows, then there's a setting for file size in the OS as well.

And you have read https://docs.moodle.org/29/en/File_upload_size , right?

In reply to ben reynolds

Re: Upload Limit - Does not work

by Joseph Formoso -

Apologies; we're running CentOS Linux.  And yes, read the manual (though the one for Moodle 1.9, which is what we're running; this is a system to use in case we need to access data in a legacy backup, and not a user-facing system).

In reply to Joseph Formoso

Re: Upload Limit - Does not work

by Ken Task -
Picture of Particularly helpful Moodlers

Check apache server for:

http://httpd.apache.org/docs/2.0/mod/core.html#limitrequestbody

'spirit of sharing', Ken

In reply to Ken Task

Re: Upload Limit - Does not work

by Joseph Formoso -

I think I ran across that when I was searching for solutions via Google, before I joined the community here.  I set LimitRequestBody to 0 in the Apache global config section a day or so ago, so request body size should be unlimited.  I've also bumped up the Timeout in Apache from 60 to 600, though the upload attempts always failed well before 60 seconds and consistently reported it as a size violation, not a timeout.  Still no joy.

In reply to Joseph Formoso

Re: Upload Limit - Does not work

by Ken Task -
Picture of Particularly helpful Moodlers

@Joseph ...

Well, let's get down to some hardcore info then.

You've mentioned CentOS ... but that's it ... I assume it's not a shared host because you've said you've changed configuration items that are normally limited/restricted/prevented on shared host ... but what is "Apache global config section"? ... that doesn't sound like command line /etc/httpd/conf/ to me.

So ... CentOS version? 32 bit or 64 bit? (reason asked ... version of moodle is 1.9)

cat /etc/redhat-release

as root user:  uname -an

also: free

Running apache as mod or cgi? 

Remotely hosted?  With whom?  Package purchased have any limits on it?

SELinux running?

fgrep 'SELINUX=' /etc/selinux/config

'spriit of sharing', Ken


In reply to Ken Task

Re: Upload Limit - Does not work

by Ken Task -
Picture of Particularly helpful Moodlers

replying to own post ... sick, but keeps in 'together' ... anyhooooo ...

@Joseph ... since we're talking 1.9 version of Moodle and probably an old version of CentOS and PHP =< 5.3 there is another way to upload rather than using Moodle ... scopy.

In the 1.9 create a hidden category/course called 'SAUPLOADS' ... system admin uploads.

The courses in a 1.9 are kept in course ID folders of moodledata.   See what course ID SAUPLOADS has been given.   In each of those course ID folders there is another folder called 'backupdata'.   Since SAUPLOADS hasn't been backed up yet, create that folder manually and make sure it's ownership/permissions a like that of other files/folders in the data folder:

cd /pathtomoodledata/[cid]/ 

mkdir backupdata

chown apache:apache backupdata

On whatever machine where you have the 1.9 large backups ... zip file.

Use scp to cp the file directly into moodledata/[SAUPLOAD_course_id_#]/backupdata/

If I were on a Mac using SCP and in the directory where that 1.9 backup was located:

scp largebackup.zip root@IPADDRESSOF19MDLSERVER:/pathtomoodledata/SAUPLOAD_courseID/backupdata/

That would prompt for root password and begin copying.

PHP is not the loop.  Apache is not in the loop.

IF you need a GUI for SCP ... there is WinSCP and CyberDuck for Mac.

There is yet another alternative but it means more work with the zip file itself and probably a last restort.

'spirit of sharing', Ken


In reply to Ken Task

Re: Upload Limit - Does not work

by Joseph Formoso -

Thanks very much for the information -- mainly on how to *find* a course's upload area, which I was having some trouble working out on my own.  I'll be keeping this page bookmarked against future problems of a similar nature.

Just this morning managed to get the upload to work.  Summing up: in an attempt to figure out where the issue was, I set up a standard, simple PHP upload script, and tested against that.  That, too, failed, suggesting a problem at the PHP level, and not necessarily anything to do with Moodle code itself.  Much fiddling around led me to setting the various post/upload maxes in PHP to 0, which finally got the uploads of files over 2GB working.  Of course, that was only my test code, but it was progress.

It was still failing in Moodle, though, and in the end I wound up making a small hack to the PHP upload code in Moodle so it doesn't set the MAX_FILE_SIZE hidden variable on the upload form.  Which sounds daft, but I was beginning to wonder if there were 32-bit-limit weirdnesses in the PHP build I'm using, and figured I'd see if I could remove anything where two numbers might be compared.  Whether or not my suspicion was accurate, this allowed me to get the upload to work in Moodle.

As I think I mentioned, this isn't a production system -- it's entirely here so our Distance Learning team can gain access to content in our Moodle archives from semesters past.  So, a small hack in the code isn't really something I'm going to fret about.

Thanks to all, again, for assistance rendered and for showing me how to get around this if it happens to crop up again.  I would hope that it doesn't, of course, but claims are that this used to work, and I know for sure that I didn't update packages, change configs, or anything like that 'twixt the time it worked and the time it stopped.  So I'm unlikely to trust it to stay fixed, as superstitious as that sounds.

In reply to Joseph Formoso

Re: Upload Limit - Does not work

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Joseph, using v1.9 is likely to be an advantage here, for files this large anyway. You can upload them directly to the moodledata folder and access them via a link in the Moodle. I can't exactly recall the method, but you don't need to use a script, if you have access to the Moodle tree. You don't really have to fiddle with core code or settings either. Not being a dev, I did exactly this for a number of really large videos that I couldn't upload otherwise and from memory, a couple of the respondents above helped me do this when I was new to Moodle. See how easy it is to forget? Don't use it, you lose it!