using arrays when uploading a file
Posted: Sat Apr 28, 2007 12:34 pm
Jcart | Please use 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:
any help would be greaty appreciated!
-matt
Jcart | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
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:Code: Select all
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";
}
#################################
}
}here's part of the form too if needed:
Code: Select all
<input name="photosnews[]" type="file" class="input" size="10" accept="image/gif, image/jpeg, image/jpg" >
<input type="hidden" name="action" value="editmultiple" />-matt
Jcart | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]