<?php
 	session_start(); 

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



$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
include("mylibrary.php");
	
	
		
	$collegemid = $_POST['collegemid'];
		 
		
		 $cdocstype = $_POST['cdocstype'];
		$n=0;
			
	 if(empty($_FILES['cdocsname']['name']) == false  )
	 {
		 
		  // Get Image Dimension
		$fileinfo = @getimagesize($_FILES['cdocsname']['tmp_name']);
		$width = $fileinfo[0];
		$height = $fileinfo[1];
	
		$simplephoto11=$_FILES['cdocsname']['name'];
		 $ext = pathinfo($simplephoto11, PATHINFO_EXTENSION);
		
		$fileexplode1 = explode(".",$simplephoto11);
		$fileend1 = end($fileexplode1);

		$cdocsname= date("YmdHis").rand(100,999).".".$fileend1;
		$cdocsname= checkvalidstring($cdocsname);
		$path = "images";
		
		  move_uploaded_file( $_FILES['cdocsname']['tmp_name'], $path ."/". $cdocsname);
		  $flag=1;
		  
		  
				$n = $n + 1;
		  
		   $eve2="insert into res_collegedocs_detail (collegemid,cdocstype,cdocsname) values($collegemid,'$cdocstype','$cdocsname')";
		 
					$re2 = mysqli_query($conn, $eve2);
		
		
	}
					
				
			
			
		
		header("Location: collegedetail.php?id=$collegemid");
			
	
?>