I have a file upload input attribute inside a regular form to upload a photo.
<form class="reg-page" action="phpMailer/sendEmail.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<label>Name <span class="color-red">*</span>
</label>
<input type="text" class="form-control margin-bottom-20" name="name" required>
</div>
<div class="form-group">
<label>Email <span class="color-red">*</span>
</label>
<input type="text" class="form-control" name="email" required>
</div>
<label class="control-label">Photo <span class="color-red">*</span>
</label>
<input type="file" class="file" name="photo">
<input type="submit" class="btn btn-apply" value="submit"></input>
</form>
I used PHP to process the POST parameters and the $_FILES parameters, but it seems that $_FILES array is empty when I try to var_dump and see if files are received by the backend.
var_dump($_FILES);
Any reason why this is happening?
Edit:
Here's my PHP file,
$msg = "";
foreach ($_POST as $key => $value) {
if ($key != "photo") {
$msg = $msg . "<br/>" . $key . " : " . $value;
}
}
echo $msg."<br/>";
var_dump($_FILES);
if(!empty($_FILES))
{
echo "Files Not Empty";
}
This prints all the $_POST parameters fine
and then
array(0) { }
for $_FILES