0

I was wondering if you can set the post_max_size only for a specific page or function (in the php.ini)?

You can set it in the .htaccess

php_value upload_max_filesize 4M
php_value post_max_size 4M

but it doesn't work for a specific page. Also the ini_set() doesn't work for a specific page.

Any suggestions?

SzymonM
  • 904
  • 8
  • 14
BramscoChill
  • 383
  • 4
  • 17
  • 1
    I think you check following url; http://stackoverflow.com/questions/6135427/increasing-the-maximum-post-size Regards, – Zubair Ahmed Mar 15 '17 at 10:20
  • Its possible with directive. Check https://stackoverflow.com/questions/10070585/php-ini-directive-per-directory-depending-of-request-uri – Kuldeep Singh Mar 15 '17 at 12:02

3 Answers3

1

Not possible, unfortunately. post_max_size (and upload_max_filesize) are used before your script is started, so the only way to set them is in .htaccess or php.ini.

upload_max_filesize cannot be changed at runtime (using ini_set).

upload_max_filesize could not be set using ini_set(). The "official" list states that it is PHP_INI_PERDIR

NID
  • 3,238
  • 1
  • 17
  • 28
  • I tried set it in the php.ini to 1 MB and in the .htaccess to 30MB in a specific folder with a php file, bud it only accapt 1MB post requests. – BramscoChill Mar 15 '17 at 10:58
  • see this : http://www.ipserverone.info/control-panel/how-to-change-php-ini-values-using-htaccess/ – NID Mar 15 '17 at 11:41
  • yeah its working for the whole domain, bud not for a specific file / folder (or function) – BramscoChill Mar 16 '17 at 08:02
0

There are 3 places you can set it: php.ini for globally on all pages .htaccess and php script for local website/ instance.

try removing your .htaccess and see if it reads from the php.ini. Just remember to also restart your server after changing the php.ini for it to take effect. if using linux, try:

sudo apachectl graceful

If that doesn't work, you will need to check your php code for the max size. if its in the code, its too broad for me to say what it is.

0

You cannot change the upload_max_filesize at runtime. If you want custom limits for different parts of your app/website you have to set the upload_max_filesize & post_max_size to the maximum value that you want to allow, and after that you have to manually force lower limits with function filesize()

for example: you set upload_max_filesize & post_max_size at 100M, and you can manually reject an upload larger that 50M at a specific page/function by checking the size of the file

nikos.svnk
  • 1,375
  • 1
  • 13
  • 24
  • Its working in the .htaccess for the whole domain, bud not for a specific page. The ini_set() is also for everything. Now I have set the post_max_size in the php.ini to the max and handled the size check in the code. – BramscoChill Mar 16 '17 at 08:41