iwiniquit Posted April 28, 2007 Share Posted April 28, 2007 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: 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: <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 Link to comment https://forums.phpfreaks.com/topic/49046-using-arrays-when-uploading-a-file/ Share on other sites More sharing options...
iwiniquit Posted April 28, 2007 Author Share Posted April 28, 2007 any ideas?? Link to comment https://forums.phpfreaks.com/topic/49046-using-arrays-when-uploading-a-file/#findComment-240526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.