<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}


date_default_timezone_set("Asia/Kolkata");
	$mdate1= date('Y-m-d H:i:s');
	$mdate2= date('Y-m-d');
	
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
	$umid=$_SESSION['umid'];

	
	//$tmdocument=$_POST['tmdocument'];
	
	
	$imgmid = $_POST['imgmid'];
	
	
	
	
		
		$total1 = count($_FILES['imgdocument']['name']);
		for( $i=0 ; $i < $total1 ; $i++ ) 
		{
			$imgdocumentname = $_POST['imgdocumentname'][$i];
			$imgname1 = $_FILES['imgdocument']['name'][$i];
			$fileexplode = explode(".",$imgname1);
			$fileend11 = end($fileexplode);
			$imgrnd=rand(100,999);
			$imgdocument = date("YmdHis").$imgrnd.".".$fileend11;
			$path = "docs";
			//	$filename111 = $filename11[1];
			
				move_uploaded_file( $_FILES['imgdocument']['tmp_name'][$i], $path ."/". $imgdocument );
				$eve2 = "INSERT INTO res_immigrationdocs_detail (imgmid,imgdocument,imgdocumentname) VALUES($imgmid,'$imgdocument','$imgdocumentname')";
				$re2 = mysqli_query($conn, $eve2);
				
				$_SESSION['msg'] = "Record has been added successfully";
			
		} 
	
		
		
		
	header('Location: immigration.php');
	
	
			
	
			
	
?>