<?php
require_once 'dao/Admission.php';
if(isset($_FILES['file']))
{
	print_r($_FILES);


echo $filename=$_FILES["file"]["tmp_name"];
$ext=substr($filename,strrpos($filename,"."),(strlen($filename)-strrpos($filename,".")));

//we check,file must be have csv extention
// if($ext=="csv")
// {
  $file = fopen($filename, "r");
         while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
         {
         $sn = $emapData[0];
        $data = array("student_name"=>$emapData[1],"class"=>$emapData[2],"form_id"=>$emapData[3]);
        print_r($data);
           $success =  $admission->import_students($data);
           if ($success) {
           	echo 0;
           }else{
           	echo 1;
           }
           //break;
         }
         fclose($file);
         echo 3;
// }
// else {
//     echo "Error: Please Upload only CSV File";
// }


}

?>