php - File Upload inside regular form not getting uploaded -
i have file upload input attribute inside regular form upload 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 process post parameters , $_files parameters, seems $_files array empty when try var_dump , see if files received backend.
var_dump($_files); any reason why happening?
edit:
here's php file,
$msg = ""; foreach ($_post $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 $_post parameters fine
and
array(0) { }
for $_files
as suggested on comments <form> (form tag) tag not have attribute class indeed causing problem.
so code solve problem be:
<form action="phpmailer/sendemail.php" method="post" enctype="multipart/form-data">
Comments
Post a Comment