前端代码如下:
<form action="" id="uploadExcel" method='GET'>
<input type="file" name="file" id="uploadFile" style="display: none;">
<input type="submit" value="查询" class="cx_submit" />
</form>
$("#uploadFile").change(function() {
var filePath = $(this).val();
if (filePath.indexOf("xls") != -1 || filePath.indexOf("xlsx") != -1) {
const file = document.getElementById('uploadFile').files[0];
const formData = new FormData();
formData.append('file', file);
$.ajax({
headers:{
"token": $("#token").val(),
},
type: 'POST',
url: $("#knowledgeUrl").val()+'admin-recite/recite/import',
data: formData,
contentType: false,
processData: false,
success: function (data) {
if (data.code == 1) {
if (data.data == '')
{
alert("导入成功!请在移动端验收,避免展示错误");
} else {
alert("模板导入失败,导入存在错误,序号:"+data.data+"请根据模板要求重新导入;");
}
location.reload();
} else {
alert(