This question already has an answer here:
I have a registration form and i also want to put form input file to select file which user want to import.
When i am putting file input form inside registration form it is showing invalid location of form and while submitting it calls both form action.
Here is my code :-
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Upload File Page</title>
</head>
<body>
<h3>Select File to Upload</h3>
<form action="RegisterForm">
<s:form action="UploadFile" method="post" enctype="multipart/form-data">
<s:file label="File" name="file"></s:file>
<s:submit value="Upload"></s:submit>
Name :<input type="text" name="name">
Age :<input type="text" name="age">
Email :<input type="text" name="email">
<input type="submit" value="Submit"/>
</s:form>
</form>
</body>
</html>
Here is my struts.xml :-
<action name="UploadFile" class="com.shivsashi.struts.actions.UploadFileAction">
<param name="filesPath">myfiles</param>
<result name="success">/UploadFileSuccess.jsp</result>
<result name="input">/UploadFile.jsp</result>
<interceptor-ref name="defaultStack">
<param name="fileUpload.maximumSize">10485760</param>
<param name="fileUpload.allowedTypes">text/plain,image/jpeg</param>
</interceptor-ref>
</action>
<action name="RegisterForm" class="com.journaldev.struts2.actions.Registeration">
<result name="success">/RegisterSuccess.jsp</result>
</action>