Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

overriding upload_max_filesize

Tags:

file

php

upload

I am trying to override my upload_max_filesize in php but I still get the value which is in my php.ini file which is 2 mb.

ini_set('upload_max_filesize','30M'); ini_set('post_max_size','30M'); echo("<br>".ini_get('upload_max_filesize')."<br>"); 
like image 453
sanders Avatar asked Jun 04 '09 09:06

sanders


People also ask

How do you fix the uploaded file exceeds the upload_max_filesize?

In order to fix this error, you need to increase the file size upload limit. That is, you need to increase the value of the upload_max_filesize directive in your php. ini file.

What should be upload_max_filesize?

The default PHP values are 2 MB for upload_max_filesize, and 8 MB for post_max_size. Depending on your host, changing these two PHP variables can be done in a number of places with the most likely being php. ini or . htaccess (depending on your hosting situation).

What is upload_max_filesize and Post_max_size?

upload_max_filesize is the maximum size of an uploaded file. This is the limit for a SINGLE file. post_max_size, on the other hand, is the limit of the entire body of the request (which may include multiple files as well as other stuff).


1 Answers

Those settings are not going to have any effect when set via ini_set.

The reason is that PHP needs those values before your script is even executed. When an upload occurs, the target script is executed when the upload is complete, so PHP needs to know the maximum sizes beforehand.

Set them in php.ini, your virtual host config, or in a .htaccess file. A typical .htaccess file would look like this:

php_value post_max_size 30M php_value upload_max_filesize 30M 
like image 96
Paul Dixon Avatar answered Oct 05 '22 01:10

Paul Dixon