Ok. I give up on this. When uploading multiple files to the server using php, what is a fail safe method to return the count of files the user has actually uploaded?
Whatever I have done so far, returns the count of all the fields in the form, and the count of the files a user uploads. So if the total fields in the form were 3 and a user uploaded only 2 files, I still get 3 as the count of file uploaded.
One place suggested using array_filter
to do this, but that's totally beyond me.
echo count($_FILES['file']['tmp_name']); //3
echo count($_FILES['file']); //3
Any fail safe method you follow and can suggest other than looping through the FILES
array size
to check for this?
My form is structured like any other:
<form action="process.php" method="post" enctype="multipart/form-data">
<div><input type="file" name="file[]"></div>
<div><input type="file" name="file[]"></div>
<div><input type="file" name="file[]"></div>
<div><input type="submit"></div>
</form>