Upload large file in php

How can I upload files larger than 2 MB in PHP, I searched on the Internet and I changed the php.ini , the line: "upload_max_filesize = 200M" , but I still can’t upload a 2 MB file.

What is the problem?

Please help me. Thanks in advance.

+4
source share
7 answers

Once I came across this problem with my WAMP server, and when I was looking for a solution, I came across this discussion. So, if someone has the same problem, this is my working solution, I hope this help:

  • I am using the WAMP stack. By reading your comment above, you are also using the WAMP stack. In case you do not know, the WAMP server has 2 (two) php.ini (in the PHP directory and the Apache directory), one for the CLI and the other for Apache itself (see php.ini on the WAMP server ). So, I create info.php to determine which php.ini is using my server, and in my case it is the one in the Apache directory (see Which PHP Ini file does my WAMP webpage use? ).

  • Open the php.ini that is used by your server , and as @Pascal Martin suggested, change upload_max_filesize and also set post_max_size , then restart the server.

  • Recheck your info.php, make sure that the upload_max_filesize and post_max_size values ​​have changed to the desired value.

  • Restart Apache.

It worked for me, hope this help.

+7
source

As you may have guessed, you should set upload_max_filesize ...


But you also need to set post_max_size (quoting):

Sets the maximum size of allowed data.
This option also affects the file upload. To upload large files, this value must be greater than upload_max_filesize .

+2
source

get the php.ini-dist file,

  • edit it to set the correct values ​​shown above.
  • rename it to php.ini
  • copy it to the WINDOWS directory
  • restart apache
+1
source

There are other options that may limit this:

 max_input_time = 600 php_value max_execution_time = 600 post_max_size = 200M 

(... and restart Apache)

0
source

Put the following code in the direction of the .htaccess file and save it.

 php_value upload_max_filesize 200M php_value post_max_size 200M php_value max_input_time 2000 
0
source

To upload a larger file, you need to change / increase the value of the post_max_size and upload_max_filesize directives from the php.ini file.

upload_max_filesize = 200M post_max_size = 201M

This will increase the download limits for a single file to 200 MB, by default - 2 MB.

0
source

Try installing it using a PHP script (above) ..

 ini_set("upload_max_filesize", "255M"); ini_set("post_max_size, "256M"); 
-2
source

Source: https://habr.com/ru/post/1347087/


All Articles