const upload = (file) => {
console.log(file);
fetch('http://localhost:8080/files/uploadFile', {
method: 'POST',
// headers: {
// //"Content-Disposition": "attachment; name='file'; filename='xml2.txt'",
// "Content-Type": "multipart/form-data; boundary=BbC04y " //"multipart/mixed;boundary=gc0p4Jq0M2Yt08jU534c0p" // ή // multipart/form-data
// },
body: file // This is your file object
}).then(
response => response.json() // if the response is a JSON object
).then(
success => console.log(success) // Handle the success response object
).catch(
error => console.log(error) // Handle the error response object
);
//cvForm.submit();
};
const onSelectFile = () => upload(uploadCvInput.files[0]);
uploadCvInput.addEventListener('change', onSelectFile, false);
<form id="cv_form" style="display: none;"
enctype="multipart/form-data">
<input id="uploadCV" type="file" name="file"/>
<button type="submit" id="upload_btn">upload</button>
</form>
<ul class="dropdown-menu">
<li class="nav-item"><a class="nav-link" href="#" id="upload">UPLOAD CV</a></li>
<li class="nav-item"><a class="nav-link" href="#" id="download">DOWNLOAD CV</a></li>
</ul>
Content-Type: multipart/form-data
요청 헤더 에 선언 할 필요가 없습니다