Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing upload_max_filesize on PHP

Tags:

php

upload

I'm using PHP 5.3.0 and have encountered something that might be a bug (in which case I'll report it) or might be me - so I'm asking to make sure.

When running this code:

<?php ini_set('upload_max_filesize', '10M'); echo ini_get('upload_max_filesize'), ", " , ini_get('post_max_size') 

I end up with:

2M, 8M 

This is despite my php.ini setting these higher:

upload_max_filesize = 10M post_max_size = 10M 

(occuring only once)

Because the error occurs after setting the value as well as it being set in php.ini I'm inclined to think it's a bug. Can anyone confirm or point me where I'm going wrong?

Update: Looks like restarting Apache fixed this - I always thought it didn't need to be restarted if you changed php.ini.

like image 309
Ross Avatar asked Jul 13 '09 22:07

Ross


People also ask

What is upload_max_filesize PHP?

In order to preserve your server's resources, hosts set a limit on the maximum size of a file that can be uploaded. This maximum, in megabytes, is defined in the upload_max_filesize directive. The upload_max_filesize directive itself is located in the php.


1 Answers

You can't use shorthand notation to set configuration values outside of PHP.ini. I assume it's falling back to 2MB as the compiled default when confronted with a bad value.

On the other hand, I don't think upload_max_filesize could be set using ini_set(). The "official" list states that it is PHP_INI_PERDIR .

like image 116
Rob Avatar answered Sep 19 '22 12:09

Rob