How to upload multiple large files in php

2019-07-29 19:25发布

I had uploaded three files to the server in php. Smaller files are uploaded correctly but when uploading larger files I get an error.

How to upload large files in php?

4条回答
Lonely孤独者°
2楼-- · 2019-07-29 19:52

You have to set your php.ini to accept larger file size: you are interested in two variables i think:

upload_max_filesize // the max size a file can have when uploaded

max_post_size  //the max size of a POST call 

Look here for reference

查看更多
时光不老,我们不散
3楼-- · 2019-07-29 20:10

If the smaller files are uploaded successfully but not the larger files, then most probably the problem is caused by the php.ini settings.

Did you check what is Maximum allowed size for uploaded files defined in your php.ini file? Find the following line in your php.ini file, there you can define the size. For example:

upload_max_filesize = 10M
查看更多
Juvenile、少年°
4楼-- · 2019-07-29 20:10

increase the memory limit with .htaccess or ini_set() function in php

查看更多
Bombasti
5楼-- · 2019-07-29 20:13

As Nicola points out, there are some variables in the php.ini you should look for:

For example, in php.ini:

 memory_limit = 384M
 post_max_size = 256M
 upload_max_filesize = 200M

What Nicola didn't mention is that constraints may also be in place on your web server. If it's nginx for example, you need to make adjustments to the configuration of your virtual host to support larger files ...

For nginx:

 client_max_body_size 150m;

For Apache:

The apache webserver has a LimitRequestBody configuration directive that restricts the size of all POST data regardless of the web scripting language in use. Some RPM installations sets limit request body to 512Kb. You will need to change this to a larger value or remove the entry altogether.

查看更多
登录 后发表回答