I am trying to use the <s:file> tag to allow uploading a file to the
server. However, this tag has to be within a larger overall form.
<s:form>
...
<s:file name="uploadCustomImageFile" />
<s:submit type="button"
action="%{siteId}/appearance/uploadCustomImage" name="Upload File"/>
...
<s:submit name=”Save” />
</s:form>
However, whenever I use the above code, I get the following error when I
click on the 'Upload File' button:
Invalid field value for field "uploadCustomImageFile"
If I wrap the <s:file> in its own <s:form>, nested within the main form, I
get the same error message:
<s:form>
...
<s:form action="%{siteId}/appearance/uploadCustomImage"
method="post" enctype="multipart/form-data">
<s:file name="uploadCustomImageFile" />
<s:submit type="button" name="Upload File" />
</s:form>
...
<s:submit name=”Save” />
</s:form>
However, if I remove the main “outer” form from my JSP, then the above
<s:file> in its own <s:form> works.
<s:form action="%{siteId}/appearance/uploadCustomImage"
method="post" enctype="multipart/form-data">
<s:file name="uploadCustomImageFile" />
<s:submit type="button" name="Upload File" />
</s:form>
However, the rest of the page doesn't work, of course.
Is it legal to nest <s:form> tags within each other? Or is there something
going wrong with the <s:file> tag?