<?php



//file uploads

   if(isset($_FILES['pdf_file'])){
      $errors= array();
      $file_name = $_FILES['pdf_file']['name'];
      $file_size =$_FILES['pdf_file']['size'];
      $file_tmp =$_FILES['pdf_file']['tmp_name'];
      $file_type=$_FILES['pdf_file']['type'];
      $file_ext=strtolower(end(explode('.',$_FILES['pdf_file']['name'])));
      
      $expensions= array("pdf");
      
      if(in_array($file_ext,$expensions)=== false){
         $errors[1]="extension not allowed, please choose a PDF file only.";
		 header('location:dashboard.php?act=my_credentials&error='.$errors[1]);
      }
      
      if($file_size > 3000000){
         $errors[2]='File size must be exatly 2MB';
		 header('location:dashboard.php?act=my_credentials&error='.$errors[2]);
      }
      
	  
		//prevent overwritten
		$now = date('Y-m-d-His');
	  
      if(empty($errors)==true){
		 $file_name= $user_id.'.'.$file_ext;
		 $file_name = $now.$file_name;
         move_uploaded_file($file_tmp,"../uploads/credential/".$file_name);
        $q=mysqli_query(dbc(),"UPDATE applicants_nce SET pdf_file='$file_name' WHERE id='$user_id'") ;
		if($q)
		header('location:dashboard.php?act=my_credentials&is= File uploaded succesfully');
		
		
		
      }
      
   }
   ?>