Changing upload_max_filesize on PHP
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
.
can't change upload_max_filesize
You can try to change it dynamically in your PHP scripts.
Like this :
<?php
ini_set('post_max_size', '2000M');
ini_set('upload_max_filesize', '2000M');
php 7 php.ini upload_max_filesize not working
i fingured out !
in my loaded php.ini
config , my error_reporting
values is E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
-> this is wrong!, so i changed it to
error_reporting: E_ALL
and then restart apache2 server,
now everything working fine !
so please note : if php.ini
have any error , it will use default value (which means upload_max_filesize
always 2M
)
Change the maximum upload file size
You need to set the value of upload_max_filesize
and post_max_size
in your php.ini
:
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
After modifying php.ini
file(s), you need to restart your HTTP server to use the new configuration.
If you can't change your php.ini
, you're out of luck. You cannot change these values at run-time; uploads of file larger than the value specified in php.ini
will have failed by the time execution reaches your call to ini_set
.
See the Description of core php.ini
directives.
I can't change the value upload_max_filesize in php.ini
Use phpinfo()
to figure out what ini file is being loaded:
- Ensure you're editing the correct file
- Ensure there is nothing below it in the file that would overwrite the previous
upload_max_filesize
Increase post_max_size and upload_max_filesize only for a specific PHP file, and not for the whole server
Take a look at the directives page, there's a column "Changeable". This shows how it's possible to change each setting, e.g only in php.ini, or with .htaccess or ini_set etc.
An explanation of each possible mode is here.
For both upload_max_filesize
and post_max_size
, the mode is PHP_INI_PERDIR
.
Entry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since PHP 5.3)
So yes, you can use entries in .htaccess files for both:
php_value upload_max_filesize 50M
php_value post_max_size 50M
Related Topics
"Connect Failed: Access Denied For User 'Root'@'Localhost' (Using Password: Yes)" from PHP Function
Download Multiple Files as a Zip-File Using PHP
Search With Comma-Separated Value MySQL
Login to Remote Site With PHP Curl
Simultaneous Requests to PHP Script
Running MySQL *.SQL Files in PHP
How to Increase Maximum Execution Time in PHP
How to Check If a Date Is in a Given Range
Check File Extension in Upload Form in PHP
Diagnosing Memory Leaks - Allowed Memory Size of # Bytes Exhausted
Get PHP to Stop Replacing '.' Characters in $_Get or $_Post Arrays
How to Call a PHP Function on the Click of a Button
Get First Key in a (Possibly) Associative Array
How to Refresh Token With Google API Client
How to Remove "Public/Index.PHP" in the Url Generated Laravel
Changing Upload_Max_Filesize on PHP
Speed Difference in Using Inline Strings VS Concatenation in PHP5