2

I have the following issue:

How to set per-script upload_max_filesize limit? I want to set a larger upload max filesize limit for a particular script (action). I know I could use .htaccess, but the problem is that all actions are being dispatched via single index.php file, which likely means for all actions .htaccess rules are the same. So is it possible to set a per-script max_upload_size for a single php script (action)?

Hope, you will be able to help me.

Thanks in advance.

  • 1
    Sometimes on shared hosting, you wont be able to access php.ini or set it via ini_set. In that case, before upload, use javascript to check the file size and allow/disallow them to upload. – Abhishek Saha Nov 02 '12 at 11:07

3 Answers3

0

Its not possible.. You have to set this upload_max_filesize at your php.ini or htaccess..

Changing upload_max_filesize on PHP

Community
  • 1
  • 1
Svetoslav
  • 4,686
  • 2
  • 28
  • 43
0

You could try to insert this code into Your PHP script (action):

ini_set('upload_max_filesize', '25M');

or at another action another value:

ini_set('upload_max_filesize', '120M');
shadyyx
  • 15,825
  • 6
  • 60
  • 95
  • Thanks. But unfortunately due to the fact that the changeable parameter of option 'upload_max_filesize' is PHP_INI_PERDIR (http://uk.php.net/manual/en/ini.list.php). So ini_set doesn't work for this option. Any other ideas? – Ilya Muromets Nov 02 '12 at 11:09
0

I probably found the solution. This will work for big_file_upload.php.

<If "%{REQUEST_URI} == '/subfolder/big_file_upload.php'" >
php_value upload_max_filesize 200M
php_value post_max_size 200M
</If>
<Else>
php_value upload_max_filesize 1M
php_value post_max_size 1M
</Else>

You may change If condition with other variables for example %{QUERY_STRING}. If you're routing to index.php?key=value then %{QUERY_STRING} == 'key=value'

Hebe
  • 661
  • 1
  • 7
  • 13