The problem
The $_FILES['file'] array is set, yet it's empty whenever I try to use it.
What I tried
- Googling
- Setting file upload to On in php.ini (both Xampp and project file root)
- Uploading one file at a time (just a wild try at fixing the problem
- Debugging the entire code for a month trying to solve this problem
What I know for a fact
- The path to the onSubmit is correct
- The name of the input in the form and the name after $_FILES['file'] is exactly the same
- The form has all it's required attributes
- The input has type="file" and multiple in it
My code for the form(HTML) and the file engine(PHP)
<html>
<form method="POST" action="../php/post.php" enctype="multipart/form-data">
<h3>Title</h3>
<input type="hidden" name="case" value=1>
<input type="title" name="pname">
<h3>Message</h3>
<input type="message" name="pmsg">
<h3>Images</h3>
<input type="file" name="pimg[]" multiple>
<input class="submit" type="submit" value="Upload">
</form>
</html>
PHP
<?php
if (!empty($_FILES['file']['pimg'])){
$noFiles = 1;
echo "Files found...\n";
} else {
$noFiles = 0;
echo "Files not found...\n";
echo (!empty($_FILES['file']['pimg']));
echo $_FILES['file']['pimg'][0];
}
?>
Output
The If determines the array is empty, the last echo causes an error