Maximum number of files being uploaded by input ty

2019-03-03 15:18发布

Possible Duplicate:
Max file number can php upload at same time

I'm trying to upload multiple files using html and php

<input type="file" name="upload[]" accept="image/gif, image/jpeg, application/x-tar, application/x-zip-compressed"  multiple="true">

in php when using

print count($_FILES['upload']);

I always get maximum 5 files even if I've selected 20 in html. What should I do to be able to upload, let's say, 20 files at a time?

2条回答
贼婆χ
2楼-- · 2019-03-03 15:38

You need to change these 2 parameters in php.ini file in order to allow this.

max_file_uploads = 20
post_max_size = 256M

This will allow you to upload 20 files at the same time, and also increase the maximum allowance for the upload file size.

查看更多
看我几分像从前
3楼-- · 2019-03-03 15:43

you may need to change in php.ini file and increase the limit of max_file_uploads (it mustbe 5 in your server now)

Also make sure to make relevant changes to these parameters (if needed)

upload_max_filesize
post_max_size
max_input_time
max_execution_time

LevSahakyan solved the problem.

He was using

for($i=0; $i<count($_FILES['upload']); $i++)

and because 'upload' is an array itself and has 5 parameters (name, type, tmp_name, error and size) it was uploading only 5 items. now he is using right parameter -

for($i=0; $i<count($_FILES['upload']['name']); $i++)
查看更多
登录 后发表回答