if(isset($_FILES['files'])) { if(is_array($_FILES)) { foreach ($_FILES['files']['name'] as $name => $value) { $file_name = explode(".", $_FILES['files']['name'][$name]); $allowed_ext = array("jpg","JPG", "jpeg", "JPEG", "png", "PNG", "gif","pdf","docx","doc"); if(in_array($file_name[1], $allowed_ext)) { $new_name = md5(rand()) . '.' . $file_name[1]; $sourcePath = $_FILES['files']['tmp_name'][$name]; $targetPath = "../httpdocs/docs/".$new_name; //$targetPath = "upload/".$new_name; move_uploaded_file($sourcePath, $targetPath); $filepath = "../docs/".$new_name; $sql = "update usertbl set aadhar = '".$_POST['aadhar']."' where userid = ".$_POST['userid']; sqlsrv_query($conn,$sql); if($_POST['pan'] != ""){ $sql2 = "update usertbl set panno = '".$_POST['pan']."' where userid = ".$_POST['userid']; sqlsrv_query($conn,$sql2); } $stmt = sqlsrv_query($conn,"select * from user_meta where userid = ".$_POST['userid']." and metakey = 'aadharpath'"); $row_count = sqlsrv_has_rows($stmt); if($row_count === false){ sqlsrv_query($conn,"insert into user_meta(userid,metakey,metavalue,Active) values (".$_POST['userid'].",'aadharpath','".$filepath."',1)"); } else { sqlsrv_query($conn,"update user_meta set metavalue = '".$filepath."' where metakey='aadharpath' and userid=".$_POST['userid']); } sqlsrv_query($conn,"insert into useractivity values(".$_POST['userid'].",'You had updated your aadhar details','" .date("dmY H:i:s"). "',1)"); echo "Updated Successfully"; } } } }
source share