Reply to Image association with form text field

Image association with form text field new!
by Kingsley, 11 years ago
I don't see how this class will $_POST my "input type="text" name="image1"
and associate it as a key value pair with my "input type="file" size="32" name="my_field[]" value="" >".

(I've removed the <> from this post so to escape browser recognition)

I've unsuccessfully used the following code in my form:
form name="form3" enctype="multipart/form-data" method="post" action="upload.php"
input type="file" size="32" name="my_field[]" value="" />
input type="text" name="image1">
input type="file" size="32" name="my_field[]" value="" />
input type="text" name="image2">
input type="file" size="32" name="my_field[]" value="" />
input type="text" name="image3">
input type="hidden" name="action" value="multiple" />
input type="submit" name="Submit" value="upload" />
/form

The images upload flawlessly, but the text is lost.

Can the global post and differentiate both types if I give them both the same
name? name="my_field[]"

I fully understand the 'foreach' code below, I just don't see where the class
will POST the different "type" values from my form then associate them.

$files = array();
foreach ($_FILES['my_field'] as $k => $l) {  
  foreach ($l as $i => $v) {    
    if (!array_key_exists($i, $files))       
      $files[$i] = array();    
    $files[$i][$k] = $v;  
  }
}
Reply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important