Home » struts-2.1.8.1-src » org.apache » struts2 » showcase » fileupload » [javadoc | source]

    1   /*
    2    * $Id: MultipleFileUploadUsingArrayAction.java 660522 2008-05-27 14:08:00Z jholmes $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
   10    * with the License.  You may obtain a copy of the License at
   11    *
   12    *  http://www.apache.org/licenses/LICENSE-2.0
   13    *
   14    * Unless required by applicable law or agreed to in writing,
   15    * software distributed under the License is distributed on an
   16    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   17    * KIND, either express or implied.  See the License for the
   18    * specific language governing permissions and limitations
   19    * under the License.
   20    */
   21   // START SNIPPET: entire-file
   22   package org.apache.struts2.showcase.fileupload;
   23   
   24   import java.io.File;
   25   
   26   import com.opensymphony.xwork2.ActionSupport;
   27   
   28   /**
   29    * Showcase action - mutiple file upload using array.
   30    *
   31    * @version $Date: 2008-05-27 10:08:00 -0400 (Tue, 27 May 2008) $ $Id: MultipleFileUploadUsingArrayAction.java 660522 2008-05-27 14:08:00Z jholmes $
   32    */
   33   public class MultipleFileUploadUsingArrayAction extends ActionSupport {
   34   
   35       private File[] uploads;
   36       private String[] uploadFileNames;
   37       private String[] uploadContentTypes;
   38   
   39       public File[] getUpload() { return this.uploads; }
   40       public void setUpload(File[] upload) { this.uploads = upload; }
   41   
   42       public String[] getUploadFileName() { return this.uploadFileNames; }
   43       public void setUploadFileName(String[] uploadFileName) { this.uploadFileNames = uploadFileName; }
   44   
   45       public String[] getUploadContentType() { return this.uploadContentTypes; }
   46       public void setUploadContentType(String[] uploadContentType) { this.uploadContentTypes = uploadContentType; }
   47   
   48       public String upload() throws Exception {
   49           System.out.println("\n\n upload2");
   50           System.out.println("files:");
   51           for (File u: uploads) {
   52               System.out.println("*** "+u+"\t"+u.length());
   53           }
   54           System.out.println("filenames:");
   55           for (String n: uploadFileNames) {
   56               System.out.println("*** "+n);
   57           }
   58           System.out.println("content types:");
   59           for (String c: uploadContentTypes) {
   60               System.out.println("*** "+c);
   61           }
   62           System.out.println("\n\n");
   63           return SUCCESS;
   64       }
   65   }
   66   // END SNIPPET: entire-file

Home » struts-2.1.8.1-src » org.apache » struts2 » showcase » fileupload » [javadoc | source]