<?php



//file uploads

   if(isset($_FILES['image'])){
      $errors= array();
      $file_name = $_FILES['image']['name'];
      $file_size =$_FILES['image']['size'];
      $file_tmp =$_FILES['image']['tmp_name'];
      $file_type=$_FILES['image']['type'];
      $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
      
      $expensions= array("jpeg","jpg","png");
      
      if(in_array($file_ext,$expensions)=== false){
         $errors[1]="extension not allowed, please choose a JPEG or PNG file.";
		 header('location:dashboard.php?error='.$errors[1]);
      }
      
      if($file_size > 50000){
         $errors[2]='File size must be exatly 50KB';
		 header('location:dashboard.php?error='.$errors[2]);
      }
      
	  
		//prevent overwritten
		$now = date('Y-m-d-His');
	  
      if(empty($errors)==true){
		 $file_name=$user_login_id.'.'.$file_ext;
		 $file_name = $now.$file_name;
         move_uploaded_file($file_tmp,"../uploads/".$file_name);
        $q=mysqli_query(dbc(),"UPDATE students_nce SET image='$file_name' WHERE id='$user_id'") ;
		if($q)
		header('location:dashboard.php?is=image uploaded succesfully');
		
		
		
      }
      
   }
   ?>