@ -5,64 +5,69 @@
< title > excel upload< / title >
< / head >
< body >
< form >
< fieldset >
< legend > 선택< / legend >
< label for = "sysSeCode" > 시스템구분< / label >
< select id = "sysSeCode" >
< option value = "01" > 공영주차장< / option >
< option value = "02" > 장사시설< / option >
< / select > < br / >
< label for = "sndngSeCode" > 발송구분< / label >
< select id = "sndngSeCode" >
< option value = "KKO-MY-DOC" > 카카오< / option >
< option value = "KT-SMS" > 공공알림문자< / option >
< option value = "E-GREEN" > e-그린< / option >
< / select > < br / >
< label > 전송일< / label >
< input type = "date" id = "sndngDt" required / > < br / >
< input type = "file"
accept="application/vnd.ms-excel,
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
id="files" name="files" required/>
< / fieldset >
< button type = "button" onclick = "handleSubmit()" > upload< / button >
< / form >
< form action = "http://localhost:8081/api/cmm/fmcExcelUpload" method = "post"
enctype="multipart/form-data">
< fieldset >
< legend > 선택< / legend >
< label for = "sysSeCode" > 시스템구분< / label >
< select id = "sysSeCode" >
< option value = "01" > 공영주차장< / option >
< option value = "02" > 장사시설< / option >
< / select > < br / >
< label for = "sndngSeCode" > 발송구분< / label >
< select id = "sndngSeCode" >
< option value = "KKO-MY-DOC" > 카카오< / option >
< option value = "KT-SMS" > 공공알림문자< / option >
< option value = "E-GREEN" > e-그린< / option >
< / select > < br / >
< label > 전송일< / label >
< input type = "date" id = "sndngDt" required / > < br / >
< input type = "file" accept = "application/vnd.ms-excel" id = "files" name = "files" required / >
< script type = "text/javascript" src = "http://code.jquery.com/jquery-3.4.1.min.js" > < / script >
< script >
function handleSubmit() {
const form = document.querySelector("form");
let sndngDt = document.querySelector("#sndngDt").value.replaceAll("-", "")
let file = document.querySelector("#files").files[0];
if(!sndngDt){
alert('전송일을 선택하세요');
return false;
}
if(!file){
alert('업로드할 파일을 선택하세요');
return false;
}
const fd = new FormData();
fd.append('sysSeCode', document.querySelector("#sysSeCode").value);
fd.append('sndngSeCode', document.querySelector("#sndngSeCode").value);
fd.append('sndngDt', document.querySelector("#sndngDt").value.replaceAll("-", ""));
fd.append('files', document.querySelector("#files").files[0]);
< / fieldset >
< button > upload< / button >
< / form >
< script >
const handleSubmit = async (event) => {
event.preventDefault();
const form = event.currentTarget;
const fd = new FormData();
fd.append('sysSeCode', document.querySelector("#sysSeCode").value);
fd.append('sndngSeCode', document.querySelector("#sndngSeCode").value);
fd.append('sndngDt', document.querySelector("#sndngDt").value.replaceAll("-", ""));
fd.append('files', document.querySelector("#files").files[0]);
const url = form.action;
const res = await fetch(url,
{method: 'post', body: fd}
);
try {
const data = await res.json();
console.log(data);
alert(JSON.stringify(data.data))
alert(JSON.stringify(data))
} catch (e) {
console.log(res)
$.ajax({
url: 'http://localhost:8081/api/biz/cmm/fmcExcelUpload',
data: fd,
cache: false,
contentType: false,
processData: false,
enctype : 'multipart/form-data',
type: 'POST',
success: function(data) {
console.log(data);
alert(JSON.stringify(data));
},
error: function(e) {
console.log(e);
alert(JSON.stringify(e));
}
});
}
}
const form = document.querySelector('form');
form.addEventListener('submit', handleSubmit);
< / script >
< / script >
< / body >
< / html >