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

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -