1

I know there are many jquery plugins available for file upload.But it just shows how can we added it in the jsp page.But i want to know that how we can deal with the files that are selected using these plugins in the backend.For example am using spring with struts2.So i want to send these files in my action class from my jsp and to store it in the server location.Any body know how can i do it.

1 Answer 1

1

userImage is the name of the <file> tag

 public class FileUploadAction extends ActionSupport{
        private File userImage;
        private String userImageContentType;
        private String userImageFileName;

        private HttpServletRequest servletRequest;

        public String execute() {
            try {
                String filePath = "yourPath";
                File fileToCreate = new File(filePath, this.userImageFileName);

                FileUtils.copyFile(this.userImage, fileToCreate);
            } catch (Exception e) {
                e.printStackTrace();
                addActionError(e.getMessage());

                return INPUT;
            }
            return SUCCESS;
        }

    }

From this tutorial

This tutorial explains multiple file upload usinf List

Sign up to request clarification or add additional context in comments.

1 Comment

am extending crudActionSupport.Can i use the above method in my action class

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.