function upload_excel_file() { $excel_file = $_FILES['excel_file']; $this->directory = PATH . "Excel_File/"; if ($excel_file['name'] != "") { if ($excel_file["type"] == "application/vnd.ms-excel") { $excel_file_upload = new upload($excel_file); $excel_file_upload->file_overwrite = true; $excel_file_upload->file_new_name_body = "student_current_enroll"; $excel_file_upload->process($this->directory); //if ($image_upload->processed) { //$this->registered(); $this->template->setAlert("File was Successfully Uploaded!..", Template::ALERT_SUCCESS); $excel_file_upload->clean(); $filename = "../Excel_File/student_current_enroll.xls"; if (file_exists($filename)) { $this->template->assign('excel_file', 'true'); } /* inserting into database table */ $excel_data = new Spreadsheet_Excel_Reader('../Excel_File/student_current_enroll.xls'); for ($y = 2; $y <= $excel_data->rowCount(); $y++) { $student_id = $excel_data->val($y, A); $lastname = $excel_data->val($y, B); $firstname = $excel_data->val($y, C); $middle_initial = $excel_data->val($y, D); if ($this->registered_student_model->isValid($student_id, $lastname, $firstname) && $this->administrator_model->isValid($student_id, $lastname, $firstname)) { $this->registered_student_model->insert($student_id, $lastname, $firstname, $middle_initial); } } /* ------------------------------- */ } else { $this->template->setAlert("You can Upload a XLS file only!..", Template::ALERT_ERROR); } } }