Reputation:
I have a multi-file upload form in PHP. I loop over the file input boxes like so:
while(list($key,$value) = each($_FILES['images']['name']))
I added a description box, so now I have description[] as another field.
How can I loop over both the files and the description boxes?
Upvotes: 1
Views: 177
Reputation: 95101
You can try working on both simultaneously
foreach ( $_FILES ['image'] ['tmp_name'] as $key => $val ) {
$fileName = $_FILES ['image'] ['name'] [$key]; // FileName
$fileDesc = $_POST['description'][$key]; // Work on Description
}
Upvotes: 1
Reputation: 1765
Most probably both have correspondily same keys. So
foreach($_FILES['images']['name']) as $k=>$v)
{
echo $v."<br>";
echo $description[$k]."<br>";
}
Upvotes: 0