I am trying to increase the value of upload_max_filesize to 10485760 (10M).
I am using:
ini_set('upload_max_filesize',10485760);
This is always returning false and the upload_max_filesize continues to be 2M.
I am using php 5.2.8 on windows and I don't have the ini_set disabled and am also not with safe mode on.
Anyone know why this doesn't work?
Thanks
The upload_max_size setting will be checked before your PHP script starts running. So by the time you change the setting, the upload already failed.
Try editing the value in the php.ini file instead of in your PHP script. Your script may not for whatever reason have permissions to override php.ini.
Check variable [post_max_size][1].
Sets max size of post data allowed.
This setting also affects file upload.
Try this:
ini_set('upload_max_filesize','100M');
is it running in apache (mod_php)? if so there are settings in apache that effect this as well.
The apache webserver has a LimitRequestBody configuration directive that restricts the size of all POST data regardless of the web scripting language in use. Some RPM installations sets limit request body to 512Kb. You will need to change this to a larger value or remove the entry altogether.
Related
I tried to raise the upload_max_filesize value in the php.ini (mamp 2.1.2 with the PHP version 5.4.10). The Server runs on port 80. I found several anwsers here but no one really applies.
When I use the phpinfo () function to get the "Loaded Configuration File" I get the path: /Applications/MAMP/bin/php/php5.4.10/conf/php.ini, but the shown configuration form the phpinfo () don't match with the configuration in my php.ini.
In my php.ini stands upload_max_filesize = 100M the phpinfo () tells me 2M.
After I edited the ini I restared the server and my machine.
So why can't I change the upload_max_filesize?
Edite:
After setting the Port to 8888 the config file is loaded correctly. Maybe there is a conflict with the Apache-Server of the OS?!
This is because MAMP and MAMP PRO overwrites php.ini with a template file every time the services are started. Therefore, to make your desired php.ini changes, you need to change the template.
In my instance using MAMP PRO on OS X, that template was found within:
/Applications/MAMP PRO/MAMP PRO.app/Contents/Resources/
In this folder, you will find several php.ini versions for each version of PHP that is available to you. You will want to edit the .ini file for the PHP version you are running. In my case, that was php5.5.10.ini. After editing, restart your MAMP and your new settings should take effect.
Also you have to edit: post_max_size and memory_limit
post_max_size integer
Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than
upload_max_filesize. If memory limit is enabled by your configure
script, memory_limit also affects file uploading. Generally speaking,
memory_limit should be larger than post_max_size. When an integer is
used, the value is measured in bytes. Shorthand notation, as described
in this FAQ, may also be used. If the size of post data is greater
than post_max_size, the $_POST and $_FILES superglobals are empty.
This can be tracked in various ways, e.g. by passing the $_GET
variable to the script processing the data, i.e. , and then checking if
$_GET['processed'] is set.
php ini core manual
Try editing /Applications/MAMP/bin/php/php5.4.10/conf/php.ini
and restart the server.
Or try to set it programmatically
ini_set('upload_max_filesize', '100M');
We have developed a web application using php. It worked perfectly until the client migrated it to VMware. Ever since some of the forms which were sent in POST are not being sent and we found out that it only happens when above a certain amount of data is being sent.
It only happens when running the application in the VMware environment.
HELP please!!
UPDATE:
In the apache_error.log file I found the following error:
PHP Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0, referer: .....
This param could only be found in the php.ini-development and php.ini-production and it was commented so I've removed the ;; and increased the value and also added the value in the php.ini file but it all being ignored as I can see in the phpinfo()
any suggestion?
PHP version 5.3.13
The max_input_vars being commented in php.ini most likely means it is using the default value. You are able to override it by uncommenting it. Commented does not mean ignored in this case.
the post_max_size parameter should also be configurable inside your php.ini file. Make sure to restart apache before testing and after changing anything in that file. In your php.ini file, find the line that says
post_max_size = 2M
(or whatever max size)
and increase it to 8M or something similar.
Your php.ini file may or may not be located at
/etc/php5/apache2/php.ini
It really varies from distro to distro.
Change the value of post_max_size in php.ini to post_max_size = 2M
or via .htaccesss add this
php post_max_size = 2M
Solved it by increasing the value of max_input_vars in the php.ini file.
This worth knowing that one of the symptoms was that the POST array was empty...
My guess is that you have a distribution configured to handle a
post_max_size
that is higher than the standard 2MB and you are sending "more" than 2MB.
You can override this using a custom php.ini or custom "php_value post_max_size 8MB" depending on the server configuration.
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?
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 executed
post_max_size - likewise
And 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.
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 !
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.
I am trying to change the max_memory parameter so I went into my php.ini and set max_memory = 500M For some reason, when I use phpinfo(), that setting still displays 128M (the default setting). I read that some hosts restrict max_memory. Is there a way to change this value manually, or override this option in a config file, or do I have to recompile php?
If you can recompile PHP, then you, obviously, have full control of the web server.
I would guess, as written in the comments, you:
Did not restart the Apache (or not the right Apache)
(as you found) You are editing the wrong ini file.
Your server simply don't have 500MB free memory
a few other things to check:
the report from phpinfo states that it is using the php.ini file that you're editing, not some more "specific" .ini file somewhere else
you haven't overridden the memory_limit variable through an apache .htaccess file or using ini_set in a PHP script somewhere
if you're in a shared environment, as Itay suggests, you may not have more than 128M available to your account, and you probably don't have access to reset apache either.
if that's the case, try making the value smaller to see if the changes you're making take effect. If they are, and you can't increase it above 128M, time to upgrade your hosting account.. otherwise, try making the change through .htaccess or ini_set in your script because those methods don't require an apache restart.
if you still can't get it to work, contact the host and ask them to make you a local copy of the global php.ini file for your account.
I can upload small size files with no problem,
but fail when the size is more than 1M.
What's the matter?
You probably need to configure the upload_max_filesize directive, in your php.ini file : PHP will not accept an upload of a file that is bigger than what this directive defines.
And note that you might also need to adjust post_max_size -- which defines the total size of data that can be POSTed (And files upload are sent via POST).
You can also take a look at the Handling file uploads section of the manual, which can give you a couple of useful informations about files upload.
Are you sure you have upload_max_filesize set correctly in php.ini?
Edit you php.ini file to allow for larger uploads.
HERE's some info
You can call echo phpinfo() and then verify your upload_max_filesize and other php environment settings. Its very possible that your script is dying because one of the max limits is being exceeded.
Depending on your environment you can either use ini_set() to change the necessary values at run-time or you can simply edit your php.ini file to set the value permanently. Please note that not all php.ini settings can be changed at run time and if you do edit php.ini, you will need to restart Apache.
As said by others check your php.in for upload_max_filesize and post_max_size settings. If they are okay and if you are using a 3rd party script for uploading, make sure the script is not limiting the max file size by doing something like:
if( $_FILES["file"]["size"] > (1024 * 1024) ) // disallow uploads > 1MB
{
// max size exceeded.
}