Frage

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?

War es hilfreich?

Lösung

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>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top