<form method="post" enctype="multipart/form-data" id="fileForm" accept-charset="UTF-8">
<div class="form-group">
<label for="exampleFormControlFile1"> 파일 선택</label>
<input type="file" class="form-control-file" id="exampleFormControlFile1" name="file">
</div>
<!-- <input type="button" class="btn btn-outline-success my-2 my-sm-0" onclick="sendFile()" id="sendFile"-->
<!-- value="파일 보내기"/>-->
<button type="button" class="btn btn-outline-success my-2 my-sm-0" id="sendFile">파일보내기</button>
</form>
폼데이터로 파일 업로드를
하는데 로컬환경에선 문제없이 한글이름이 들어간 파일이 잘 올라가고 읽힘.
웹 배포시 한글파일은 읽지못하는 경우가 생김
<form> 태그에 accept-charset="UTF-8" 속성 추가 를 했지만 여전히 문제. 그래서
try {
fileName = StringUtils.cleanPath(new String(file.getOriginalFilename().getBytes("8859_1"), StandardCharsets.UTF_8));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
파일 이름을 지정할때 인코딩을 해줌
fileName = StringUtils.cleanPath(new String(file.getOriginalFilename().getBytes("8859_1"), StandardCharsets.UTF_8));
'개발환경설정, 플러긴, 기타 . . > 문제해결' 카테고리의 다른 글
gradle .jar 배포시 manifest... (0) | 2019.11.15 |
---|