Polaris Nation Polaris Nation - 1 year ago 104
PHP Question

Count in upload files in codeigniter

I can't understand why this happen;

I select 3 files in postman and _POST it.

But it always return 5.

I think count($_FILES['filename']) return files count number but it is not.

So I check the file size and count it, same return, 5.

This is my codeigniter code, it is simple.

If you know about it, please help me

enter image description here
enter image description here

Answer Source


It will always return 5 because the Image element that you are posting from PostMan isn't a array.

Second thing is when you post a file to a script it always have

$_FILES['Image'] => array(
    [name] => '',
    [type] => '',
    [tmp_name] => '',
    [error] => '',
    [size] =>''

So use the Image name as Image[] , make sure you have square backets"[]" after the Image key name.

Right now everytime you write count($_FILES['Image']); It will return 5. Use [] in the key name

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download