Empty $_FILES array with enctype="multipart/form-data"

This is strange. I have a form to upload photos. Here is my form tag:

<form enctype=“multipart/form-data” action=“<?$_SERVER[“PHP_SELF”];?>” method=“post”>

With the enctype=“multipart/form-data” in the form tag, print_r($photos); returns nothing. If I remove the enctype, it shows the contents of my array.

Not sure what to do here. Any help is greatly appreciated.

Show us your full HTML form and also possibly the script after your form is submitted.

Ok. Here is a little test form I created:


<form enctype="multipart/form-data" action="test.php" method="post">
<input type="file" name="photos[ ]"><br>
<input type="file" name="photos[ ]"><br>
<input type="file" name="photos[ ]"><br>
<input type="file" name="photos[ ]"><br>
<input type="submit">
</form>

Here is the code to display the file names:


$photos = $_POST['photos'];
foreach ($photos as $s) {
  echo "$s<br />";
}

With the enctype in the form tag, it returns nothing. Without, it displays the file names.

Thanks logic_earth. That worked, I don’t know how I missed that.

Because files are not put in “_POST” they are contained in “_FILES”