<?php
    include'../../connect/db.php';
    session_start();
    csrf_verify();
    $user = $_SESSION['chap'];
    $id = $_POST['upload_id'];
	$target_dir = "../../e-banking/assets/images/uploads/".$user."/";
    $target_file = $target_dir . basename($_FILES["profile_pic"]["name"]);
    $image_file = basename($_FILES["profile_pic"]["name"]);
    $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
    
     // Allow certain file formats
    	if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
				&& $imageFileType != "gif" ) {
				    echo "invalid";
				    
					exit();
				    $uploadOk = 0;
				}
    
    if( move_uploaded_file($_FILES["profile_pic"]["tmp_name"], $target_file) ) {
        
      $sql = mysqli_query($con,"UPDATE users SET kyc = '$image_file', status = 'review' WHERE email = '$user' ");
      
      if( $sql ){
        echo"success";
      }
      else{
         echo mysqli_error($con);
      }
      
    } 
    else{
        echo"error2";
    }

?>