$file = $_FILES['excel']['tmp_name']; $excel_array = ExcelReader::readXLS($file); if ($_POST['cover'] == 'on') { Complaint::delDataByMonth($_POST['table'], $tmp[1]); } else { $check = false; $check = Complaint::checkFirstLine($excel_array, $_POST['table']); } if ($check) { $error[$_POST['table']][] = $check['error']; } else { // TODO check if imported if ($excel_array) { array_shift($excel_array); $error[$_POST['table']] = array(); $record_id = Complaint::recordTable($_FILES['excel']['name'], $table, $date, $province_id, $user_info['user_id']); foreach ($excel_array as $key => $value) { $r = Complaint::save($value, $table, $date, $province_id, $record_id); if (!$r) { file_put_contents('../error_' . date('Y-m-d') . '.log', date('Y-m-d H:i:s') . ' ' . $_FILES['excel']['name'] . ' \'' . implode("','", $value) . "'\n", FILE_APPEND); $error[$_POST['table']][] = '\'' . implode("','", $value) . "'<br>"; } } if (empty($error[$_POST['table']])) { $error[$_POST['table']][] = '导入成功!'; } } else { $error[$_POST['table']][] = "导入文件有问题!"; } } }