Reputation: 3106
I am trying upload larger files so I set this in php code
ini_set('upload_max_filesize', '1000M');
ini_set('post_max_size', '1100M');
ini_set('memory_limit', '1200M');
but $_POST and $_FILES are empty. But when I change php.ini settings it works. Why it doesn't change setting on the fly?
Upvotes: 2
Views: 2307
Reputation: 1314
Have a look at these :
http://www.php.net/manual/en/ini.list.php
http://www.php.net/manual/en/configuration.changes.modes.php
After reading, it seems that the only option that you can modify with ini_set
is memory_limit
.
The others 2 being configurable in the php.ini file, in httpd.conf, .htaccess, or in a per directory .user.ini file.
Meaning, if you want to change these values, you must have access to your server's configuration ! You won't be able to afford that from within the script !
Upvotes: 3
Reputation: 798456
The first two settings are not allowed to be changed per script, but even if they were it still would not be effective since the files/POST data must be handled before the script is even run, which means that the settings wouldn't have a chance to take effect.
Upvotes: 1
Reputation: 145472
It's too late to have those settings changed after PHP has started.
upload_max_filesize
- uploads happen before the PHP script runs and your ini_set() is executedpost_max_size
- likewiseAnd even if you could change memory_limit
(depends on server configuration), it would be too late again if you expect that big of an upload.
See ini_set()
and http://www.php.net/manual/en/ini.list.php for more info.
Upvotes: 4