When a user clicks on the upload button after selecting a file from their computer, where does that file goes? Can i use that file's content if a temp file is made? How can i do that? I need my user to upload a file and then validation is performed on that file's content? Any ideas?
Asked
Active
Viewed 395 times
1 Answers
2
It depends on your application how its handles file uploads. In a Spring application, it is common to use apache commons FileUpload.
org.springframework.web.multipart.commons.CommonsMultipartResolver
(that extends from CommonsFuleUploadSupport
) has a property uploadTempDir
. That can be used to specifiy where the uploaded file is temporary stored.
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="100000" />
<property name="uploadTempDir" ref="uploadTempDirResource" />
</bean>
<bean id="uploadTempDirResource"
class="org.springframework.core.io.FileSystemResource">
<constructor-arg value="/temp" />
</bean>

Ralph
- 118,862
- 56
- 287
- 383