Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upload large file in php

Tags:

php

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

What seems to be the problem?

Please help me.Thanks in advance.

like image 479
Surej Avatar asked Apr 07 '11 11:04

Surej


People also ask

How can I upload large files over 500mb in PHP?

By changing the upload_max_filesize limit in the php. ini file. By implementing file chunk upload, that splits the upload into smaller pieces an assembling these pieces when the upload is completed.

What is the maximum upload file size in PHP?

To increaes file upload size in PHP, you need to modify the upload_max_filesize and post_max_size variable's in your php. ini file. In addition, you can also set the maximum number of files allowed to be uploaded simultaneously, in a single request, using the max_file_uploads . Note that from PHP 5.3.

How can I upload more than 2 MB in PHP?

by default PHP will not handle file uploads larger than 2MB, if one requires PHP to handle larger files then one must set upload_max_filesize and post_max_size in your php. ini file to be larger than 2MB.


1 Answers

Once upon a time I'm facing this problem with my WAMP server, and when I search for solution, I stumbled upon to this discussion. So, if someone have the same problem, this is my working solution, I hope this help:

  1. I'm using WAMP stack. By reading your comment above, you are using WAMP stack too. In case you don't know, WAMP server has 2 (two) php.ini (in PHP directory and Apache directory) configuration, one for CLI and the other for Apache itself ( see php.ini on WAMP server ). So, I create info.php to detect which php.ini use by my server, and in my case that is the one in Apache directory ( see Which PHP Ini file does my WAMP webpage uses?).

  2. Open your php.ini that used by your server, and as @Pascal Martin suggested, change upload_max_filesizeand also set post_max_size then restart your server.

  3. Check again your info.php, make sure the value of upload_max_filesize and post_max_size has changed to your desired value.

  4. Restart Apache.

It's worked for me, hope this help.

like image 98
Seto Avatar answered Sep 29 '22 18:09

Seto