# Using arrays when uploading a file

**URL:** https://forum.kirupa.com/t/using-arrays-when-uploading-a-file/224071
**Category:** Uncategorized
**Created:** [April 28, 2007, 4:51am UTC](https://forum.kirupa.com/t/using-arrays-when-uploading-a-file/224071 "2007-04-28T04:51:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![iwiniquit](https://avatars.discourse-cdn.com/v4/letter/i/7993a0/32.png) [@iwiniquit](https://forum.kirupa.com/u/iwiniquit)
#### Post date: [April 28, 2007, 4:51am UTC](https://forum.kirupa.com/t/using-arrays-when-uploading-a-file/224071/1 "2007-04-28T04:51:04Z")

</div>

i’m trying to upload multiple files using arrays…which works fine…but i’m specifically trying to define a variable based on the number of the array.

here’s my code to see what i mean:

```auto
    if ($_POST['action'] == 'editmultiple')
        $files = array();
    foreach ($_FILES['photosnews'] as $k => $l) {    
        foreach ($l as $i => $v) {
            if (!array_key_exists($i, $files)) 
                $files[$i] = array();
            $files[$i][$k] = $v;
              ##### THIS IS WHERE I'M HAVING TROUBLE ####
            if ($_FILES['photosnews'] == 1) { 
                $vartest = "this is one";
            } else {
                $vartest = "this is not one";
            }
              #################################
        }
    }

```

so my logic is that each file has a specific array number starting from 0…when the file has an array number of 1, i want to set a variable to something…and then if it’s 2, i want it to set to something different…i’m just not sure what to put in that if statement so that it knows what array number does what. i’m thinking maybe a for statement would be better…but i’m not sure how to get it work with what i have so far.

here’s part of the form too if needed:

```auto
<input name="photosnews[]" type="file" class="input" size="10" accept="image/gif, image/jpeg, image/jpg" >
<input type="hidden" name="action" value="editmultiple" />

```

any help would be greaty appreciated!

-matt
