PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Zied ALAYA -
Number of replies: 12

I want to increase the size of files I can upload. I updated the values of php.ini serttings file but when I try to upload any file bigger then 10Mo I got an error. Any idea please ? (Moodle 3.5.1 ; Ubuntu server 18.04 ; Apache 2 ; PHP 7.2)

/etc/php7.2/apache2/php.ini
          ; Maximum allowed size for uploaded files.
          upload_max_filesize = 60M
          ; Maximum size of POST data that PHP will accept.
          post_max_size = 60M
          ; Maximum amount of memory a script may consume (128MB)
          memory_limit = 128M


in coursesettings administration page , I have already moodlecourse | maxbytes is set to 60Mo after I updated php.ini file.
other setting values :

  • moodlecourse | maxbytes is set to 60Mo.
  • workshop | maxbytes is set to 60Mo.
  • assignsubmission_file | maxbytes is set to 20Mo.
  • forum_maxbytes is set to 20Mo.
  • maxbytes  is set to 60Mo.


I checkek in VirtualHost files and there is no varaible with LimitRequestBody.
Any idea please ?

Average of ratings: -
In reply to Zied ALAYA

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Is that *definitely* the ruling php.ini file? Don't say 'yes'. In Moodle, Site administration > Server > PHP Info. It says near the top which php.ini file(s) it is loading. 

I assume you restarted Apache after making changes to php.ini?

In reply to Howard Miller

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Zied ALAYA -
Yes I restarted apache. I tried to change values and Moodle detect and set the new maximum value each time.
following your advice, I double checked PHP Info, and it's the one I modified :
Configuration File (php.ini) Path         /etc/php/7.2/apache2

In reply to Zied ALAYA

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Colin Fraser -
Picture of Documentation writers Picture of Testers

I found that in nGnix there was more than one php.ini file. Most times, upload sizes did not get changed unless I made the same edit in all files, irrespective of what the path to ini file said in the PHP Info display. Do a find for all php.ini files and see what you get. 

In reply to Colin Fraser

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Zied ALAYA -

thanks for the hint but did not solve my issue. I changed upload_max_filesize = 60M ,   post_max_size = 240M  in all php.ini files and still have the same message "The file 'file_name' is too large and cannot be uploaded".

$ sudo find -iname php.ini
./etc/php/7.0/apache2/php.ini
./etc/php/7.2/apache2/php.ini
./etc/php/7.2/cgi/php.ini
./etc/php/7.2/cli/php.ini

In reply to Zied ALAYA

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Zied ALAYA -
I fond that there is a .htaccess in the moodle website directory.
I installed Moodle via git and it was created automatically. Here the .htaccess content:

php_value upload_max_filesize 838 860 800
php_value post_max_size 838 860 800
php_value max_execution_time 600
if I suppose that 838860800 is in Bit, it will be 100Mo but in my case a file with 13Mo size is rejected.

What should I do ?
In reply to Zied ALAYA

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

"I installed Moodle via git and it was created automatically"

No it doesn't. Well, no it shouldn't. That's a bit of a worry. "Normal" Moodle doesn't do that so you really need to ask yourself how that .htaccess file got there. 

There's nothing else around is there? That is, have you installed Moodle under some other application (Wordpress?) that could be causing this?

In reply to Howard Miller

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Zied ALAYA -

hmmm, other application yes (phpmyadmin via apt command).

May be it was the source of problem but I don't think so (it did not creates such file in other servers I have).

I changed html/.htaccess but it did not solve the issue

php_value upload_max_filesize 60M
php_value post_max_size 240M
php_value max_execution_time 600
I deleted it also but still got the same error.

I fond 2 other htaccess under moodledata (I never created this files) : moodledata/.htaccess and moodledata/temp/.htaccess

here moodledata/.htaccess

deny from all
AllowOverride None

and here moodledata/temp/.htaccess

deny from all
AllowOverride None
Note: this file is broken intentionally, we do not want anybody to undo it in subdirectory!


In reply to Zied ALAYA

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The moodledata ones are correct and are nothing to do with it. 

Go to Site administration > Server > PHP Info. 

Find the upload_max_filesize, post_max_size settings in the list. What does it say?

Average of ratings: Useful (1)
In reply to Howard Miller

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Zied ALAYA -

Thanks for the information about .htaccess of moodledata.

Site administration > Server > PHP Info  says :

upload_max_filesize 
   60M
post_max_size
  240M




In reply to Zied ALAYA

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Zied ALAYA -

I finally discovered the source of the problem and solved smile

It's in the course settings:

d

Thanks every body for your precious help and time smile

In reply to Zied ALAYA

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Hahahahahaaaaaa! The one thing we didn't mention...big grin - ROFLMAO

That's OK, we're all experts at this.... 

Average of ratings: Useful (2)
In reply to Colin Fraser

Re: PHP - Ubuntu 18.04: maximum upload limit is always 10Mo

by Zied ALAYA -

big grin big grin that's right Colin.

the good point is that I know more things about "my" Moodle server after all this verifications