File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts 2 upload problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 upload problem" Watch "struts 2 upload problem" New topic

struts 2 upload problem

Winson Sun

Joined: Oct 29, 2007
Posts: 2
When i use struts 2 upload file , in action, i can't get the upload file value. Can anybody help me? thanks in advance.


<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<s:form action="upload" method="POST" enctype="multipart/form-data">
<s:file name="uploads" label="upload file 1" /><br>
<s:file name="uploads" label="upload file 2" /><br>

public class UploadAction extends ActionSupport {

private static final long serialVersionUID = 1L;

private File[] uploads; // The actual file

private String[] uploadsContentType;// The content type of the file

private String[] uploadsFileName;// The uploaded file name and path

... ...

<action name="upload" class="com.pcz.spms.struts.UploadAction"
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
<param name="maximumSize ">
<!--<interceptor-ref name ="defaultStack"/> -->
<result name="success">/display.jsp</result>

in aciton, uploads value is null.
[ October 30, 2007: Message edited by: Winson Sun ]
Rahul Nair
Ranch Hand

Joined: Dec 01, 2007
Posts: 138

I also have the same problem.... For Large Size File the property value null!

can you please help us ?


I agree. Here's the link:
subject: struts 2 upload problem
It's not a secret anymore!