How to upload files which are larger than 2 MB

Category: Tools

If you want to upload files using PHP to a server which are larger than 2 MB and there is a limit (e.g. 2 MB) on the server, you can do following steps:

  • See your PHP Info - create file called e.g. info.php and add following php code to this file:

 


echo phpinfo();

 

  • Run this file on your server and you will see all PHP settings
  • See upload_max_filesize directive

 

alt

 

It is your server:

  • If there is only 2M (2 MB), you should increase your upload filesize in your php.ini
  • Open your php.ini (linux: /etc/php.ini, windows: C:\WINDOWS or C:\WINNT) and change or add the following piece of code:

 

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Maximum allowed size for uploaded files
upload_max_filesize = 4M

 

  • Save your php.ini and restart your server

It is not your server:

  • Try to add the following code to your index.php file (or your main script file):

 

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

 

  • If it doesn't work, you must contact your server support.

 

Powered by Phoca