File: /home/bibuzptr/tvetelearning.bibu-edu.us/admin/importData.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use PhpSpreadsheet\src\PhpSpreadsheet\Reader\Xlsx;
if(isset($_POST['aa'])){
// Allowed mime types
$excelMimes = array('text/xls', 'text/xlsx', 'application/excel', 'application/vnd.msexcel', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
// Validate whether selected file is a Excel file
if(!empty($_FILES['file']['name']) && in_array($_FILES['file']['type'], $excelMimes)){
// If the file is uploaded
if(is_uploaded_file($_FILES['file']['tmp_name'])){
$reader = new Xlsx();
$spreadsheet = $reader->load($_FILES['file']['tmp_name']);
$worksheet = $spreadsheet->getActiveSheet();
$worksheet_arr = $worksheet->toArray();
// Remove header row
unset($worksheet_arr[0]);
foreach($worksheet_arr as $row){
echo $first_name = $row[0];
$last_name = $row[1];
$email = $row[2];
$phone = $row[3];
$status = $row[4];
}
$qstring = '?status=succ';
}else{
$qstring = '?status=err';
}
}else{
$qstring = '?status=invalid_file';
}
}else{
echo "111";
}
echo $qstring;
// Redirect to the listing page
//header("Location: index.php".$qstring);
?>