102

I have try to put these 2 lines

php_value post_max_size 30M
php_value upload_max_filesize 30M

In my root .htaccess file but that brings me "internal server error" message.

php5 is running on the server

I don't have access to php.ini so I think htaccess is my only chance.
Can you tell me where the mistake is?

cottontail
  • 10,268
  • 18
  • 50
  • 51
T1000
  • 2,909
  • 7
  • 36
  • 53

7 Answers7

149

php_value upload_max_filesize 30M is correct.

You will have to contact your hosters -- some don't allow you to change values in php.ini

Kerry Jones
  • 21,806
  • 12
  • 62
  • 89
  • 2
    Thank you but ini_set() is not working for upload_max_filesize and post_max_size :/ – T1000 Jun 07 '10 at 19:27
  • when you say "not working" do you mean, not bringing about the desired result / producing an error / something else? – Kerry Jones Jun 07 '10 at 19:29
  • set error_reporting( E_ALL ) and see if anything shows. Other than that, contact your host provider, they should be able to help you. Some block changes to such variables as they don't want you to become a major trafficked site. – Kerry Jones Jun 07 '10 at 19:43
  • 15
    These options can not be set by ini_set(). See http://www.php.net/manual/en/ini.list.php and http://php.net/manual/en/configuration.changes.modes.php – dev-null-dweller Jun 07 '10 at 19:54
  • 1
    Many hosts dont allow this but you can also create a php.ini file, put it in the root of the site and override the values there. – Erik Čerpnjak Jan 27 '15 at 18:54
42
php_value memory_limit 30M
php_value post_max_size 100M
php_value upload_max_filesize 30M

Use all 3 in .htaccess after everything at last line. php_value post_max_size must be more than than the remaining two.

Stephan Vierkant
  • 9,674
  • 8
  • 61
  • 97
VAPP Group
  • 421
  • 4
  • 3
  • 2
    may I know the reason why `php_value post_max_size` must be more than the remaining two? – Anusha Apr 17 '18 at 13:27
  • @Anusha if you think about it, you could be doing a post with two 30M files + more textual data, and that will cost some additional bytes, that's probably the reason – giovannipds Apr 07 '20 at 20:03
40

If you are getting 500 - Internal server error that means you don't have permission to set these values by .htaccess. You have to contact your web server providers and ask to set AllowOverride Options for your host or to put these lines in their virtual host configuration file.

dev-null-dweller
  • 29,274
  • 3
  • 65
  • 85
  • Thank you. The error log gave some nonsense about invalid command, which is a far throw from "Go change your virtual host configuration file." – Altimus Prime Jul 14 '18 at 03:27
  • 1
    If you are getting a 500 internal server error an alternative solution would be to use a '.user.ini' file to change the settings. By adding 'post_max_size = 30M' and 'upload_max_filesize = 30M' – Dan Feb 28 '22 at 18:39
13

What to do to correct this is create a file called php.ini and save it in the same location as your .htaccess file and enter the following code instead:

upload_max_filesize = "250M"
post_max_size = "250M"
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Shaishav Shah
  • 157
  • 1
  • 6
3

If your web server is running php5, I believe you must use php5_value. This resolved the same error I received when using php_value.

mbinette
  • 5,094
  • 3
  • 24
  • 32
2

I also face internal server error message for inserting php_value upload_max_filesize 5M in my .htaccess file in PHP Laravel Project from c-Panel.

Then I solve it by the following logic -

  1. Create a file named - .user.ini in my Project root Directory
  2. Insert the following code in .user.ini file
upload_max_filesize = 5M  
post_max_size = 5M  
Sanaulla
  • 1,329
  • 14
  • 13
-2

Both commands are correct

php_value post_max_size 30M 
php_value upload_max_filesize 30M 

BUT to use the .htaccess you have to enable rewrite_module in Apache config file. In httpd.conf find this line:

# LoadModule rewrite_module modules/mod_rewrite.so

and remove the #.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • 7
    IMHO, to enable the use of .htaccess, all you need to do is set `AllowOverride` to anything but `none`. Loading the `rewrite_module` is only required for ModRewrite-directives. – RonaldPK Jun 03 '16 at 16:32