Hi,

I tried the same last week for the first time, and here is my experience:
1.
WARN [org.apache.struts2.components.File] (default task-5) Struts has detected 
a file upload UI tag (s:file) being used without a form set to method 'POST'. 
This is probably an error!
I used <s:form> and it was rendered automatically to method=post but to get rid 
of the warning I had to set it manually
<s:form action="myAction" enctype="multipart/form-data" method="POST">
2.
MyAction.java looks pretty much the same as your HelloAction.java.
But it helped me to use "newLogo" instead of "upload" in jsp and action class.
3.
I did not use any of your struts.xml configuration.
a)
<interceptor-ref name="actionFileUpload" />
<interceptor-ref name="basicStack" />
I think "actionFileUplad" is enclosed in the "defaultStack".
I do not know about this "basicStack" you copied from the documentation example.
b)
<constant name="struts.multipart.parser" value="jakarta" />
<constant name="struts.multipart.maxSize" value="10485760" /> <!-- 10MB -->
<constant name="struts.multipart.saveDir" value="C:
temp"/> <!-- Ruta absoluta -->
Your saveDir looks strange to me.
I use the default saveDir which turned out as a Wildfly tmp directory, and then 
save to my targetPath with:
Files.copy( ( (File) newLogo.getContent() ).toPath(), targetPath, 
StandardCopyOption.REPLACE_EXISTING );
4.
You did not give much info on your jsp.
Here is my part: <s:file name="newLogo" accept="image/*"/>

Perhaps you can strip down with less struts.xml configuration to find a 
solution to your problem.
Good luck
Ute


> Gesendet: Samstag, 10. Mai 2025 um 05:42
> Von: "Jesus Moreno" <jesus...@gmail.com>
> An: user@struts.apache.org
> Betreff: File Upload Failure in Struts 7.0.3 Migration - UploadedFilesAware 
> Implementation Issue
>
> I'm migrating an application from Struts 2.5 to 7.0.3 and encountering
> persistent issues with file upload functionality despite following the
> documentation.
> 
> The UploadedFile object remains null in my action class, even with:
> 
> - Correct UploadedFilesAware implementation
> - Proper multipart form configuration
> - Debug logs showing no uploaded files (ActionFileUploadInterceptor reports
> empty acceptedFiles)
> 
> Logs show:
> 
> 2025-05-09 01:00:25 DEBUG ActionFileUploadInterceptor:179 - No files have
> been uploaded/accepted
> 2025-05-09 01:00:25 WARN File:79 - Struts has detected a file upload UI tag
> (s:file) being used without a form set to method 'POST'
> (Despite <s:form method="POST" enctype="multipart/form-data"> being
> correctly declared)
> 
> Basic action:
> // Action
> public class HelloAction extends ActionSupport implements
> UploadedFilesAware {
>     public UploadedFile upload; // Always null
> 
>    @Override
>     public String execute() {
>  //do something with the file
>     return SUCCESS;
>    }
>     @Override
>     public void withUploadedFiles(List<UploadedFile> uploadedFiles) {
>         if (!uploadedFiles.isEmpty()) {
>              //This never execute cause always is empty
>             this.upload = uploadedFiles.get(0); // Never reached
>         }
>     }
> }
> struts.xml:
> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts
> Configuration 6.5//EN"
>     "https://struts.apache.org/dtds/struts-6.5.dtd";>
> <struts>
> <constant name="struts.multipart.parser" value="jakarta" />
>     <constant name="struts.multipart.maxSize" value="10485760" /> <!-- 10MB
> -->
>     <constant name="struts.multipart.saveDir" value="C:
> temp"/> <!-- Ruta absoluta -->
>       <package name="default" extends="struts-default">
> 
>       <action name=""><result>/hello.jsp</result></action>
> 
>         <action name="hello"
> class="mx.com.jeser.ejemplo.actions.HelloAction">
>             <interceptor-ref name="actionFileUpload" />
>         <interceptor-ref name="basicStack" />
>           <result name="success">/success.jsp</result>
>           <result name="input">/input.jsp</result>
>           <result name="error">/error.jsp</result>
>         </action>
>     </package></struts>
> 
> We are trying to implement the new features according the follow docs for
> version 7.0.3:
> 
> https://struts.apache.org/security/#defining-and-annotating-your-action-parameters
> https://struts.apache.org/core-developers/action-file-upload-interceptor
> 
> I would greatly appreciate your assistance in identifying if we might be
> overlooking any undocumented requirements or configurations.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to