I have a form which includes a file upload. Everything in the form seems to be working fine except that the $_FILES['file']['name'] turns up empty.
HTML
<form ... >
<input class="file" type="file" name="file[]" />
<input class="file" type="file" name="file[]" />
<input class="file" type="file" name="file[]" />
</form>
PHP
foreach ($_FILES['file']['name'] as $index => $file) {
// Handle file upload
}
I get an error saying that the index $_FILES['file'] is not defined. I’ve checked that file upload is enabled in PHP. What else could be causing this to turn up empty?
Is the enctype right?
Try
Without enctype no files will be uploaded, so the
$_FILESarray will be empty.