Im so confused about the uploads[]

I’ve got a form where I allow many uploads into Images

<input type="file" id="picupload" class="picupload" click-type="type2" name="Image[]" accept="image/*" />

When I submit the form and try to see what was uploaded

foreach ($_FILES["Image"] as $key => $entry)
{
     print $key . ": " . $entry . "<br>";
}

The result is…,.
FILES[‘Image’]
name: Array
type: Array
tmp_name: Array
error: Array
size: Array
Warning: Invalid argument supplied for foreach() in /hermes/walnaweb10a/b2054/moo.teamluke/svr/add_rental.php on line 358
I thought I set things up right (How do I open that array inside another array?

The foreach() loop is expecting an array.

Before the foreach() loop, examine the $_FILES variable.

<?php

echo '<pre>';
  var_dump( $_FILES );
echo '</pre>';

exit;


**Edit:** The print statement is expecting a string.

Immediately after the foreach() loop try this:

echo '<pre>';
  var_dump( $entry );
echo '</pre>';

exit;

ok, found some stuff out, w hen I do

$Images = $_FILES["Image"];


foreach ($Images['name'] as $key => $entry)
{
     print $key . ": " . $entry . "<br>";
}
  

I get
0: png_image.png
Warning: Invalid argument supplied for foreach() in /hermes/walnaweb10a/b2054/moo.teamluke/svr/add_rental.php on line 359

should I worry about the warning?

Yes you should worry. As @John_Betong said, in order to print the array so that you know what data is in it and how to properly obtain it and go through it you can do something like:

echo "<pre>";
print_r($_FILES);
echo "</pre>";
die();

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.