How can I get original filename of an uploaded file in Struts2. Currently what I am getting is a filename.tmp filename whereas the file being uploaded is a CSV and the filename is different to what I am getting. Here is the JSP code
Select file Change RemoveHere is the action mapping in struts config
<action name="survey/send" class="surveyAction" method="send">
<interceptor-ref name="authorizationStack"/>
<interceptor-ref name="fileUpload">
<param name="maximumSize">20971520</param>
</interceptor-ref>
<result name="success" type="tiles">orgAdmin.survey.send.settings</result>
<result name="input" type="tiles">orgAdmin.survey.send.settings</result>
<result name="error" type="tiles">orgAdmin.survey.send.settings</result>
</action>
Action class contains the following 3 instance variables instance with getter and setter
public File upload;
private String contentType;
private String filename;
However, upload.getName()
is not getting the actual filename, whereas contentType
and filename
properties are null
.