<?php

include('server.php');

$username = $_SESSION['username'];
  
/* Getting file name */
$filename = $_FILES['file']['name'];
  
/* Location */
$location = "upload/".$filename;
$uploadOk = 1;
  
if($uploadOk == 0){
   echo 0;
}else{
   /* Upload file */
   if(move_uploaded_file($_FILES['file']['tmp_name'], $location)){

	$sql = 'insert into batchimport(filename, uploadby, status) value("' . $filename . '","' . $username . '","queued")';
	if(mysqli_query($db, $sql)) {

	$last_id = $db->insert_id;
	}
	
	echo "CSV File Uploaded Successfully \n Your Batch ID:   $last_id \n  Please wait while and check the batch status";
	
   }else{
      echo 'CSV Upload Failed, Please try again!';
   }
}
?>
