ini_set("upload_max_filesize","200M") not working in php [duplicate]

Possible Duplicate:
overriding upload_max_filesize

i use these code for change upload file size :-

echo ini_get('upload_max_filesize').'<br/>';
ini_set("upload_max_filesize","300M");
echo ini_get("upload_max_filesize");

BUT I GOT

2M
2M

which is set in php.ini.

i want to change file upload size limit.


Solution 1:

  1. http://php.net/manual/en/ini.list.php

upload_max_filesize "2M" PHP_INI_PERDIR

  1. http://php.net/manual/en/configuration.changes.modes.php

PHP_INI_PERDIR Entry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since PHP 5.3)

So you can't use ini_set for this.

Solution 2:

You need to increase post_max_size as well.

To upload large files, this value must be larger than upload_max_filesize

You may also need to increase memory_limit

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.

As others have pointed out, upload_max_filesize cannot be changed at runtime (using ini_set). However, once you have changed it correctly you will still need to increase these values.