Thursday, April 14, 2016

How to find out maximum upload size in php

In php you can set the maximum upload file size for your application, which is i believe you can set on php.ini file, but the question is how to see this maximum file size from the coding?

On php code, you can use php built in function called ini_get() with parameter of string 'upload_max_size' to get the maximum file size that has been set on php.ini file.

$size = ini_get('upload_max_filesize');
echo $size;

I think the default file size is around 2Mb, you can change it if you want by editing the php.ini file, go to the upload section, and look for 'upload_max_filesize'.

; File Uploads ;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20

You can also find information about maximum upload file size using the phpinfo() function which will generate special page showing all information about your php configuration, including maximum upload file size.

No comments:

Post a Comment