파일 업로드 시 에러 발생
org.springframework.web.multipart.MultipartException:
Failed to parse multipart servlet request; nested exception is java.io.IOException:
임시 파일 업로드 위치 [C:\uploadfile]은(는) 유효하지 않습니다.
>
원인 : 파일 업로드 시 필요한 파싱이 안 되어있음.
해결
1. Tomcat server - context.xml
Multipart 처리를 위해서는 allowCasualMultipartParsing 옵션을 꼭 추가해야 함.
<!-- Multipart 처리 위한 옵션 -->
<Context allowCasualMultipartParsing="true" path="/">
<Resources cachingAllowed="true" cacheMaxSize="100000" />
2. web.xml - url 경로 확인
<!-- Multipart Config -->
<multipart-config>
<location>C:\\uploadfile\\</location>
<!-- 업로드 되는 파일 저장 공간 -->
<max-file-size>20971520</max-file-size>
<!-- 업로드 되는 파일의 최대 크기 -->
<max-request-size>41943040</max-request-size>
<!-- 한번에 올릴 수 있는 최대 크기 -->
<file-size-threshold>20971520</file-size-threshold>
<!-- 특정 사이즈의 메모리 사용 -->
</multipart-config>