Upload multiple files WITH correct pairs of form fields into Database

In my form page, I would like to allow 3 files upload and 3 corresponding text fields, so that the filename and text description can be saved in database table in correct pair. Like this:
INSERT INTO table1 (filename,desc) VALUES('photo1.jpg','happy day');
INSERT INTO table1 (filename,desc) VALUES('photo2.jpg','fire camp');
INSERT INTO table1 (filename,desc) VALUES('photo3.jpg','christmas night');
However, using the commons fileupload, http://commons.apache.org/fileupload/, I don't know how to reconstruct my codes so that I can acheieve this result.
if(item.isFormField()){
}else{
}I seems to be restricted from this structure.
The jsp form page
<input type="text" name="description1" value="" />
<input type="file" name="sourcefile" value="" />
<input type="text" name="description2" value="" />
<input type="file" name="sourcefile" value="" />The Servlet file
package Upload;
import sql.*;
import user.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Date;
import java.util.List;
import java.util.Iterator;
import java.io.File;
import java.io.PrintWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.*;
public class UploadFile extends HttpServlet {
private String fs;
private String category = null;
private String realpath = null;
public String imagepath = null;
public PrintWriter out;
private Map<String, String> formfield = new HashMap<String, String>();
  //Initialize global variables
  public void init(ServletConfig config, ServletContext context) throws ServletException {
    super.init(config);
  //Process the HTTP Post request
  public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");
    response.setCharacterEncoding("utf-8");
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    Thumbnail thumb = new Thumbnail();
    fs = System.getProperty("file.separator");
    this.SetImagePath();
     boolean isMultipart = ServletFileUpload.isMultipartContent(request);
     if(!isMultipart){
      out.print("not multiple part.");
     }else{
         FileItemFactory factory = new DiskFileItemFactory();
         ServletFileUpload upload = new ServletFileUpload(factory);
         List items = null;
         try{
            items = upload.parseRequest(request);
         } catch (FileUploadException e) {
            e.printStackTrace();
         Iterator itr = items.iterator();
         while (itr.hasNext()) {
           FileItem item = (FileItem) itr.next();
           if(item.isFormField()){
              String formvalue = new String(item.getString().getBytes("ISO-8859-1"), "utf-8");
              formfield.put(item.getFieldName(),formvalue);
              out.println("Normal Form Field, ParaName:" + item.getFieldName() + ", ParaValue: " + formvalue + "<br/>");
           }else{
             String itemName = item.getName();
             String filename = GetTodayDate() + "-" + itemName;
             try{
               new File(this.imagepath + formfield.get("category")).mkdirs();
               new File(this.imagepath + formfield.get("category")+fs+"thumbnails").mkdirs();
               //Save the file to the destination path
               File savedFile = new File(this.imagepath + formfield.get("category") + fs + filename);
               item.write(savedFile);
               thumb.Process(this.imagepath + formfield.get("category") +fs+ filename,this.imagepath + formfield.get("category") +fs+ "thumbnails" +fs+ filename, 25, 100);
               DBConnection db = new DBConnection();
               String sql = "SELECT id from category where name = '"+formfield.get("category")+"'";
               db.SelectQuery(sql);
                while(db.rs.next()){
                  int cat_id = db.rs.getInt("id");
                  sql = "INSERT INTO file (cat_id,filename,description) VALUES ("+cat_id+",'"+filename+"','"+formfield.get("description")+"')";
                  out.println(sql);
                  db.RunQuery(sql);
             } catch (Exception e){
                e.printStackTrace();
        HttpSession session = request.getSession();
        UserData k = (UserData)session.getAttribute("userdata");
        k.setMessage("File Upload successfully");
        response.sendRedirect("./Upload.jsp");
  //Get today date, it is a test, actually the current date can be retrieved from SQL
  public String GetTodayDate(){
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
    String today = format.format(new Date());
    return today;
  //Set the current RealPath which the file calls for this file
  public void SetRealPath(){
    this.realpath = getServletConfig().getServletContext().getRealPath("/");
  public void SetImagePath(){
    this.SetRealPath();
    this.imagepath = this.realpath + "images" +fs;
}Can anyone give me some code suggestion? Thx.

When one hits the submit button - I then get a 404 page error.What is the apaches(?) error log saying? Mostly you get very useful information when looking into the error log!
In any case you may look at how you are Uploading Multiple Files with mod_plsql.

Similar Messages

  • Powershell program to upload multiple files with version control at the file level

    I have a network folder which contains multiple files refreshed daily.I then run a power
    shell scrip which uploads all the files . I have scheduled it to run once
    daily. I have version control at the directory level , is there a way to upload all the files daily and maintain the last X versions for each file , rite now it does it at a folder level . I want it at a file level
    powershell script
    if((Get-PSSnapin "Microsoft.SharePoint.PowerShell") -eq $null)
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    #Script settings
    $webUrl = "http://sharepoint.contoso.com/Corporate/Sales/"
    $docLibraryName = "Shared Documents"
    $docLibraryUrlName = "Shared Documents\arizona" # specify your subfolder url here
    $localFolderPath = "C:\Test"
    #Open web and library
    $web = Get-SPWeb $webUrl
    write-host $webUrl
    $docLibrary = $web.Lists[$docLibraryName]
    write-host $docLibrary
    $files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles()
    write-host $files
    ForEach($file in $files)
    if($file.Name.Contains(".pdf"))
    write-host $file
    #Open file
    try
    $fileStream = ([System.IO.FileInfo] (Get-Item $file.FullName)).OpenRead()
    #Add file
    $folder = $web.getfolder($docLibraryUrlName)
    write-host "Copying file " $file.Name " to " $folder.ServerRelativeUrl "..."
    $spFile = $folder.Files.Add($folder.Url + "/" + $file.Name,[System.IO.Stream]$fileStream, $true)
    write-host "Success"
    #Close file stream
    $fileStream.Close();
    catch
    Write "Error: $file.name: $_" >>c:\logfile.txt
    continue;
    #Dispose web
    $web.Dispose()

    Check if this helps you
    http://blogs.technet.com/b/heyscriptingguy/archive/2013/04/28/weekend-scripter-use-powershell-to-upload-a-sharepoint-file-version.aspx
    # Add the Snapin
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    # Retrieve specific Site
    $spWeb = Get-SPWeb http://SP01
    # Create instance of Folder
    $spFolder = $spWeb.GetFolder("Shared Documents")
    # Get the file on Disk that we want to upload
    $file = Get-Item C:\Documents\MyDoc.docx
    # upload the file.
    $spFolder.Files.Add("Shared Documents/MyDoc.docx",$file.OpenRead(),$false)
    $newVersion = $spFolder.Files.Add($spFile.Name, $file.OpenRead(), $spFile.Author, $spFile.ModifiedBy, $spFile.TimeCreated, (Get-Date))
    If this helped you resolve your issue, please mark it Answered

  • 2 Form Fields into one DB Entry

    I apologize in advance if this question has been asked and answered multiple times. I am new to this and extremely frustrated because I keep getting stuck.
    I am using Dreamweaver to create a website with Coldfusion as the server. I am using Quickbooks and QODBC to use the DB to integrate with CF.
    I have created a form with multiple fields all text entries. I have been able to get all the information to post into my database correctly. However my question is I want to create a multiple entry that would combine two form fields into one column in the database table. For instance I have First Name and Last Name as form fields when the user submits I want these to both enter into their respective columns in the table but also combine into one entry with format Last Name, First Name into a FULL NAME Column in the table. Is this possible if so how????? Thanks in advance.

    This is my current code::
    <cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
    <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "customer">
      <cfquery datasource="QBs">  
        INSERT INTO Customer (Name, FirstName, LastName, BillAddressAddr1, BillAddressAddr2, BillAddressCity, BillAddressState, BillAddressPostalCode)
    VALUES (<cfif IsDefined("FORM.lastname") AND #FORM.lastname# NEQ "">
    <cfqueryparam value="#FORM.lastname#" cfsqltype="cf_sql_clob" maxlength="41">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.firstname") AND #FORM.firstname# NEQ "">
    <cfqueryparam value="#FORM.firstname#" cfsqltype="cf_sql_clob" maxlength="25">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.lastname") AND #FORM.lastname# NEQ "">
    <cfqueryparam value="#FORM.lastname#" cfsqltype="cf_sql_clob" maxlength="25">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.firstname") AND #FORM.firstname# NEQ "">
    <cfqueryparam value="#FORM.firstname#" cfsqltype="cf_sql_clob" maxlength="41">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.streetaddress") AND #FORM.streetaddress# NEQ "">
    <cfqueryparam value="#FORM.streetaddress#" cfsqltype="cf_sql_clob" maxlength="41">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.city") AND #FORM.city# NEQ "">
    <cfqueryparam value="#FORM.city#" cfsqltype="cf_sql_clob" maxlength="31">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.state") AND #FORM.state# NEQ "">
    <cfqueryparam value="#FORM.state#" cfsqltype="cf_sql_clob" maxlength="21">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.zipcode") AND #FORM.zipcode# NEQ "">
    <cfqueryparam value="#FORM.zipcode#" cfsqltype="cf_sql_clob" maxlength="13">
    <cfelse>
    </cfif>
      </cfquery>
    <cfquery datasource="Access">
    INSERT INTO Logininfo (FirstName, LastName, Username, Password)
    VALUES (<cfif IsDefined("FORM.firstname") AND #FORM.firstname# NEQ "">
    <cfqueryparam value="#FORM.firstname#" cfsqltype="cf_sql_clob" maxlength="25">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.lastname") AND #FORM.lastname# NEQ "">
    <cfqueryparam value="#FORM.lastname#" cfsqltype="cf_sql_clob" maxlength="25">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.username") AND #FORM.username# NEQ "">
    <cfqueryparam value="#FORM.username#" cfsqltype="cf_sql_clob" maxlength="25">
    <cfelse>
    </cfif>
    , <cfif IsDefined("FORM.password") AND #FORM.password# NEQ "">
    <cfqueryparam value="#FORM.password#" cfsqltype="cf_sql_clob" maxlength="25">
    <cfelse>
    </cfif>
    </cfquery>
      <cflocation url="thankyou.cfm">
    </cfif>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <h1>Welcome to our sign up Page!</h1>
    <p>Please fill out the form below to register with out site and gain access to our members account page.</p>
    <form name="customer" action="<cfoutput>#CurrentPage#</cfoutput>" method="POST" id="customer"><table width="auto" border="1">
      <tr>
        <td><label for="firstname">
          <div align="right">First Name:</div>
          </label></td>
        <td><span id="sprytextfield1">
          <input type="text" name="firstname" id="firstname" accesskey="n" tabindex="05" />
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
        <td><label for="lastname">
          <div align="right">Last Name:</div>
          </label></td>
        <td><span id="sprytextfield2">
          <input type="text" name="lastname" id="lastname" accesskey="n" tabindex="10" />
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
        <td><label for="streetaddress">
          <div align="right">Street Address</div>
          </label></td>
        <td><span id="sprytextfield3">
          <input type="text" name="streetaddress" id="streetaddress" accesskey="n" tabindex="15" />
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
        <td><label for="city">
          <div align="right">City:</div>
          </label></td>
        <td><span id="sprytextfield4">
          <input type="text" name="city" id="city" accesskey="n" tabindex="20" />
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
        <td><label for="state">
          <div align="right">State:</div>
          </label></td>
        <td><span id="sprytextfield5">
          <input type="text" name="state" id="state" accesskey="n" tabindex="25" />
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
        <td><label for="zipcode">
          <div align="right">Zipcode:</div>
          </label></td>
        <td><span id="sprytextfield6">
          <input type="text" name="zipcode" id="zipcode" accesskey="n" tabindex="30" />
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
        <td><label for="username">
          <div align="right">Username:</div>
        </label></td>
        <td><span id="sprytextfield7">
          <input type="text" name="username" id="username" accesskey="n" tabindex="40" />
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
        <td><label for="password">
          <div align="right">Password:</div>
        </label></td>
        <td><span id="sprypassword1">
          <input type="password" name="password" id="password" accesskey="n" tabindex="45" />
          <span class="passwordRequiredMsg">A value is required.</span></span></td>
      </tr>
      <tr>
        <td colspan="2"><div align="center">
          <input type="submit" name="submit" id="submit" value="Register" accesskey="n" tabindex="50" />
        </div></td>
        </tr>
    </table>
      <input type="hidden" name="MM_InsertRecord" value="customer" />
    </form>
    <script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
    var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4");
    var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5");
    var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6");
    var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7");
    var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1");
    </script>
    </body>
    </html>

  • Getting error while uploading multiple files in sharepoint hosted app in 2013 with REST API

    Hi All,
    In one of my tasks, I was struck with one issue, that is "While uploading multiple files into custom list with REST API".
    Iam trying to upload multiple files in library with REST calls for an APP development, my issue is if i wants to upload 4 image at once its storing only
    3 image file and further giving "Conflict" error". Below is the attached screenshot of exact error.
    Error within screenshot are : status Code : 409
    status Text :conflict
    For this operation i am uploading different files as an attachment to an list item, below is the code used for uploading multiple files.
    my code is
    function PerformUpload(listName, fileName, listItem, fileData)
        var urlOfAttachment="";
       // var itemId = listItem.get_id();
        urlOfAttachment = appWebUrl + "/_api/web/lists/GetByTitle('" + listName + "')/items(" + listItem + ")/AttachmentFiles/add(FileName='" + fileName + "')"
        // use the request executor (cross domain library) to perform the upload
        var reqExecutor = new SP.RequestExecutor(appWebUrl);
        reqExecutor.executeAsync({
            url: urlOfAttachment,
            method: "POST",
            headers: {
                "Accept": "application/json; odata=verbose",
                "X-RequestDigest": digest              
            contentType: "application/json;odata=verbose",
            binaryStringRequestBody: true,
            body: fileData,
            success: function (x, y, z) {
                alert("Success!");
            error: function (x, y, z) {
                alert(z);

    Hi,
    THis is common issue if your file size exceeds 
     upload a document of size more than 1mb. worksss well for kb files.
    https://social.technet.microsoft.com/Forums/office/en-US/b888ac78-eb4e-4653-b69d-1917c84cc777/getting-error-while-uploading-multiple-files-in-sharepoint-hosted-app-in-2013-with-rest-api?forum=sharepointdevelopment
    or try the below method
    https://social.technet.microsoft.com/Forums/office/en-US/40b0cb04-1fbb-4639-96f3-a95fe3bdbd78/upload-files-using-rest-api-in-sharepoint-2013?forum=sharepointdevelopment
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • How to upload a file with a HTML form into a BLOB ?

    Hi,
    I want to upload a file into a BLOB.
    I have created a procedure in PL/SQL whitch generates an html form.
    You can upload a file with <input type="file" name="my_file">.
    How can I insert this file into my database ?
    Thank's for your Help
    Estelle

    Hi Estelle,
    Portal Applications forum is a more apporpriate forum for such questions. Please post your question there.
    Thanks,
    Ravi

  • How can I upload multiple files in a master detail relationship?

    I would like to be able to upload several files for one record (a one to many relationship). I tried using a master detail form, but the tabular form does not support file browse. I've searched the forum and found several examples asking how to upload multiple files at once. That is not what I'm trying to do. I simply want the user to browse, select a file, provide a file name and description. Then select the next file. When they are done selecting files (it may be one file or many files) I want them to hit the submit button and I'll run a procedure that saves the files to the database.
    How can I do this? Thanks, you guys are the best. Elizabeth

    Elizabeth,
    I had this situation come up once and here's what I did, thought it may not be exactly what you're looking for.
    I created a collection to store the ID's of the files that had been uploaded, along with the key and other information. The file browse input will upload your files into the wwv_flow_files table on submit. I was storing the documents in another application table.
    The after submit process grabs the id from wwv_flow_files where the name is = to your file input.
    After you add that ID and your associated master key in the collection, your final submit process fetches the files from wwv_flow_files and inserts them into your own table.
    I can put an example on apex.oracle.com if that would be helpful.
    Thanks,
    Jeff

  • SystemManager.as : 'should never get here' when uploading multiple files

    I have a code for uploading multiple files. The code works so that when complete event from the first upload is received, the second upload is started. The code works fine on Flash Player 9, but now when I changed my compiler settings to require version 10, the program no longer works.
    Also this only seems to occur when I execute the code from the Flash Builder. I have compiled the code with ant requiring FP version 10. This swf is bundled inside a war and can executed without any problems. I actually set the ant compiler to require FP 10 some time ago already.
    I get error 2174, which is for trying to upload multiple files at the same time. Although, I don't understand why I get this, since the uploads should not be done simultaneously as I explained above.
    The interesting thing here is when I try to debug it. At some point when stepping in the code, I get the following error thrown. It's thrown by the code pasted at the end. Interesting is the else block that throws the error, the comment says 'should never get here'.
    A bug in the framework or in Flex Builder?
    Using IE 8 with FP 10.0.32.18 (on Win XP if that matters).
    Thanks.
    Error
         at mx.managers::SystemManager/updateLastActiveForm()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:5087]
         at mx.managers::SystemManager/activateForm()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2352]
         at mx.managers::SystemManager/activate()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\SystemManager.as:2307]
         at mx.managers::FocusManager/creationCompleteHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\FocusManager.as:1592]
         at flash.events::EventDispatcher/dispatchEventFunction()
         at flash.events::EventDispatcher/dispatchEvent()
         at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
         at mx.core::UIComponent/set initialized()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1169]
         at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:718]
         at Function/http://adobe.com/AS3/2006/builtin::apply()
         at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8628]
         at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8568]
         private function updateLastActiveForm():void
              // find "form" in the forms array and move that entry to
              // the end of the array.
              var n:int = forms.length;
              if (n < 2)
                 return;     // zero or one forms, no need to update
              var index:int = -1;
              for (var i:int = 0; i < n; i++)
                 if (areFormsEqual(form, forms[i]))
                      index = i;
                      break;
              if (index >= 0)
                 forms.splice(index, 1);
                 forms.push(form);
              else
                 throw new Error();     // should never get here

    Thanks for the reply Alex.
    In both cases the URL is http. The only difference is that in one case everything is on server inside a war running on Tomcat to which I make connection via browser. In the other case the server side stuff is running on local computer on Tomcat and the Flex code is not bundled inside the war.
    In both cases the URL is in form of http://... When running locally, the URL is http://localhost:8080/myAppName. I don't know how the network card driver translates this URL, but what you said might have something to do with it.

  • URGENT: Is it possible to upload multiple files using STRUTS

    Hi,
    Is it possible to upload multiple files using STRUTS.
    I am able to upload a single file. But how do i upload multiple files ??
    upload.jsp
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html>
    <head>
    <title>New Page 1</title>
    </head>
    <body>
    <html:form action="/secure/uploadFile.do" enctype="multipart/form-data" method="POST" type="com.smartstream.webconnect.user.actions.UploadActionForm">
    <p>File to upload
    <html:file property="fileUpload" size="20"/></p>
    <p><html:submit/></p>
    </html:form>
    </body>
    </html:html>
    UploadAction.java
    public class UploadAction extends BaseAction {
        Logger log = Logger.getLogger(AttachMessageAction.class);
        public ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ActionException {
            System.out.println("executeAction of UploadAction");
            UploadActionForm uploadActionForm = (UploadActionForm) form;
            int fileSize = uploadActionForm.getFileUpload().getFileSize();
            System.out.println("uploadActionForm.getFileUpload().getFileSize() = " + uploadActionForm.getFileUpload().getFileSize());
            byte buffer[] = new byte[1024];
            try {
                BufferedInputStream bufferedInputStream = new BufferedInputStream(uploadActionForm.getFileUpload().getInputStream());
                FileOutputStream fos = new FileOutputStream("s:\\uploaded\\" + uploadActionForm.getFileUpload().getFileName());
                int read;
                while ( (read = bufferedInputStream.read(buffer,0,buffer.length)) != -1) {
                    fos.write(buffer, 0, read);
                fos.flush();
                fos.close();
                bufferedInputStream.close();
                return mapping.findForward("success");
            } catch (IOException e) {
                e.printStackTrace();
                return mapping.findForward("error");
            }catch(OutOfMemoryError o){
                o.printStackTrace();
                System.out.println("o.getMessage() " + o.getMessage());
                return mapping.findForward("error");
    UploadActionForm.java
    public class UploadActionForm extends ActionForm{
        private FormFile fileUpload;
        private byte[] fileContent;
        public FormFile getFileUpload() {
            org.apache.struts.taglib.html.FormTag _jspx_th_html_form_0;
            return fileUpload;
        public byte[] getFileContent() {
            return fileContent;
        public void setFileUpload(FormFile fileUpload) {
            this.fileUpload = fileUpload;
        public void setFileContent(byte[] fileContent) {
            this.fileContent = fileContent;
    }--Bhupendra Mahajan

    Yes, you could try using the multipart handler...
    But I have a better idea...
    Determine the maximum number of file uploads that the
    user can do at one time. I mean, you can't
    realistically have the user upload a million files at
    one time. So say the max is 20. So you create your
    action form class with 20 FormFile fields called file1
    to file20.
    Then when you dynamically create your page, you
    dynamically create the specified number of file fields
    and 1 hidden field called "totalFiles" which contains
    the number of file fields you created. This should be
    an int field in the form bean.
    Then when you do your action processing, you just loop
    thru the totalFiles... Or well, actually, you may not
    need that at all. You could just check all the
    FormFile fields and whatever ones aren't null contain
    files.But what about UploadActionForm.java[b]
    How do i have exact mapping of the HTML form in this file ??
    --[b]Bhupendra Mahajan

  • How to check-in multiple files with same name having different revision num

    Hi
    Can anyone please tell me, how to check-in multiple files with the same name with different revision number using RIDC API.
    For eg:
    First I will check-in a file(TestFile.txt) into a content server with revision number 1 using RIDC API in ADF application. Then after some time, will modify the same file(TestFile.txt) and check-in again. I tried to check-in same file multiple times, however first time its checking-in correctly into server showing revision as 1, while checking-in same file again, its not giving any errror message, and also its not reflecting in server. Only one file(TestFile.txt) is reflecting in server.
    How to implement this functinality using RIDC API? Any suggestions would be helpful.
    Regards
    Raj
    Edited by: 887680 on Mar 6, 2013 10:48 AM

    Hi Srinath
    Thanks for your response. Its not cloning, its like check-in file first, then check-out the file and do some editing and then again upload the same file with different revision number using RIDC. I got the solution now.
    Regards
    Raj

  • How to upload multiple files into a server location at a single time

    Hi All,
    In my application i need to send multiple files from a particular page into the server location. In this page there will be an option to upload a file and after selecting the file , we will have an option asking if we were interested to send another file. It works just similar to google mail where we can multiple files at the same time. Right now though i had coded the uploading files concept i am facing some problems when trying to upload multiple files. All the files are being appended to a single file but i want them to be placed as different files at the specified location. Plz help me in this regard...
    Thanks in advance................,,

    Hi,
    i am sending the code in my prg. Have a look at it.
    var multi_selector = new MultiSelector( document.getElementById( 'files_list' ),3);
    In the above line i am specyfying that the maximum no. of files to be uploaded is 3. So if i upload less than 3 files, the program doesn't work and is not reading the uploaded files. If i upload 3 files it works fine. So please suggest me how to make this work irrespective of the no. of files uploaded using apache commons.
    My code is as follows:
    <form action="./servlet/Sample" method = "post" enctype="multipart/form-data">
         <!-- The file element -- NOTE: it has an ID -->
         <input id="my_file_element" type="file" name="file_1" >
         <input type="submit" name="submit1" value="submit">
    </form>
    Files:
    <!-- This is where the output will appear -->
    <div id="files_list"></div>
    <script>
         <!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->
         var multi_selector = new MultiSelector( document.getElementById( 'files_list' ),3);
         <!-- Pass in the file element -->
         multi_selector.addElement( document.getElementById( 'my_file_element' ) );
    </script>

  • Unable to upload multiple files on FTP server.

    m trying to upload files present in one directory..
    its storing the first file properly...but from second file its giving error.
    my code is pasted below:
    ftp1.setFileType(FTPClient.BINARY_FILE_TYPE);
    ftp2.setFileType(FTPClient.BINARY_FILE_TYPE);
                 String filename="";
                FTPFile[] files = ftp1.listFiles();
                if ( files.length == 0 )
                    System.out.println("  No results.");
                } else
                     for (int i = 0; i < files.length; i++)
                          FTPFile f = files;
              filename = f.getName();      
              System.out.println(" > " + filename );
              ftp2.enterRemotePassiveMode();
         ftp1.enterRemoteActiveMode(InetAddress.getByName(ftp2.getPassiveHost()),
              if (ftp1.remoteRetrieve(filename) && ftp2.remoteStore(filename))
                   System.out.println("Successfull >" + filename);
              else
                   System.err.println(
                   "Couldn't initiate transfer. Check that filenames are valid.");
                   break __main;
         }//end of for
         ftp1.completePendingCommand();
         ftp2.completePendingCommand();
    }// end of else
    my code is actually trying to list files from FTP Server1 and copy this to FTP Server2.
    I think the problem is
    ftp2.enterRemotePassiveMode();
         ftp1.enterRemoteActiveMode(InetAddress.getByName(ftp2.getPassiveHost()),
    please can any one figure out the problem...
    any help suggestion is welcome....

    What about connecting to the remote server with cfftp. Then
    using
    cfdirectory to get a listing of the files. Loop over the
    listing using cfftp
    to grab each file.
    Bryan Ashcraft (remove brain to reply)
    Web Application Developer
    Wright Medical Technology, Inc.
    Macromedia Certified Dreamweaver Developer
    Adobe Community Expert (DW) ::
    http://www.adobe.com/communities/experts/
    "Dusty Carr" <[email protected]> wrote in message
    news:f59tue$731$[email protected]..
    >I need to get files from a remote server using cfftp, the
    problem is that
    > the files are not zipped into one file, there are
    multiple files with
    > different file names that change daily, all are .jpg
    extensions. I
    > thought
    > I could just use something like this:
    > <cfftp action = "getFile"
    > stopOnError = "Yes"
    > remotefile = "/*.jpg"
    > localfile = " my dir"
    > connection = "ftp_IDX"
    > failIfExists = "false"
    > passive="yes">
    >
    > But just using the * wildcard does not work. what am I
    missing here?
    >
    >

  • Unable to upload multiple files

    In MOSS, I am unable to upload multiple files from the Site Actions | Manage Content and Structure | New | Item menu. I have tried adding Word documents and image files (JPEG, GIFS) to no avail into the \images or \document folders. Even if I try just one file, three or five, the menu never initiates or progresses. It just sits. If I cancel, the menu returns immediately. I have tried to change security settings with no success. Trying to upload multiple files on different MOSS installations also fails. If this is related to a Web Dev settings, can you tell me exactly where the setting is? Thanks for your insight. cm

    Believe it or not, I have found a solution after about 4hrs of fiddling around. This appears to be a bug in Sharepoint 2007. There is a work around that I have discovered! Follow the steps below and let me know if this works for you. It has worked for me and other people so far.
    The steps are as follows:
    1) Browse to your website at http://<servername>/_layouts/settings.aspx; you will need to login by providing a service account name & password or your site collection administrator account & password.
    2) Once you login, click on 'Site Actions' menu.
    3) Then, click on 'Manage Site Content and Structure'.
    4) Click on any document library you want to upload or add files into. If you do not see the 'Upload' menu from the dropdown main menu between the 'New' and 'Actions' menu then you have this bug as well showing up on your server. Don't give up yet, there is a solution. Keep going through these steps!
    5) Click on 'New' and select 'Item'.
    6) You should now see the Upload Document page; under the input browse field there should be a link for 'Upload Multiple Files...', if you do not see this you will need to install either Office 2003 or Office 2007. If you do see it, click on it.
    7) Now, you should see the multiple upload page that allows you to select multiple files. If you try to select one or several and click on the OK button, nothing will happen. No need to worry! There is a work around. Just keep reading to the next step.
    8) On the hierarchy navigation you will have links something like this:
    WebSiteName > Folder1 > Folder2
    9) Click on the "Document Library" folder name; in our case it was Folder1. Basically its the folder you ended up in in step #4.
    10) Now, did you notice anyting in your menu change? Now you should be able to see the Upload menu option between the 'New' and 'Actions' menu that you could not see in step #4.
    11) Click on the 'Upload' menu and select 'Upload Multiple Documents'
    12) Now, you will be back at the Upload document page where you were in step #7
    13) Select one file or many and then click OK. Now it works!!! You should get an IE popup asking you that your about to upload files to your site, Click OK.
    VOILA!!!
    Don't ask me why, I do not know why this happens but it works.

  • How to upload multiple files using af:inputfile

    Hi,
    I am using J dev 11.1.1.3. I have a requirement wherein i need to upload multiple files using af:inputfile. Can we do in it ADF ? Is there any other work around to implement the same. I have checked previous questions but not able to find proper solution for this.
    Any pointer in this regard is highly helpful.
    Regards,
    Kalyan

    You have to do this your self by either (as vinod said) using a different component (not present in adf) or implementing this:
    1) allow the user to select multiple filenames (somehow)
    2) zip them together
    3) upload the zip
    4) unpack the zip on the server
    5) work with the files
    Timo

  • How to upload multiple files using wicket

    Hai,
    how to upload multiple files using wicket at a single browse.
    any suggestion?
    Thanks in advance

    You have to do this your self by either (as vinod said) using a different component (not present in adf) or implementing this:
    1) allow the user to select multiple filenames (somehow)
    2) zip them together
    3) upload the zip
    4) unpack the zip on the server
    5) work with the files
    Timo

  • How to upload multiple files in Webdynpro using File upload Screen Element

    Hi Experts,
          Can anybody tell me how to upload multiple files/pdfs in webdynpro using file upload screen element, and also please tell me what is the maximum storage limit of RAWSTRING data type,Advance Thanks.
    Regards,
    Sandesh

    Hi Sandesh,
    this is simply not supported, not in WebDynpro nor in standard HTML.
    A workaround is to upload a ZIP with all files and on server side unpack the ZIP and operate on the single files.
    I hope it will  help u..
    ----------------------OR-------------------------
    As you know using File upload UI element we can upload only one file at a time. There may be a scenario where user may want to upload any no of files at a time which is not determined at design time. This can be acheived using the ACF UpDownload UI element which requires a security whiltelist to be created
    http://scn.sap.com/docs/DOC-2270
    ----------------------OR-------------------------
    You can use Table UI element.
    Regards,
    Deepak Singh

Maybe you are looking for

  • Want to load my NEW iPod and give my old one to someone else

    I received a new iPod. My daughter is inheriting the old one and she has no interest in my music - surprise! I want to wait to load the new before wiping the old. Can I load the new one before wiping the old - just in case? I saw the instructions for

  • Using JAAS in JSP

    Hello Everyone, I am new to java and I am trying to get a jaas implementation completed. I am trying to create a jsp that will accept the username and password and then pass it on the jaas provider. Has anyone had a success with a jaas implementation

  • Abap Routines in BW

    Hai, Where the Abap Routines are used in BW side? How many routines are there in bW? Can any send me the Doc's on this to my mail id [email protected] full points  assured. thanks n Regards prashanth k

  • Problem in starting oracle

    hi, I have a problem with starting Oracle du to a power cut. I dont have any backup. i wasn't able to startup in mount mode but after recreating the control file i can now start in mount mode but i can't open the database. I have now when i try to st

  • Digital voice recorder (olympus)

    I have an Olympus DVR (WS-300M) that claims to be Mac compatible. I cannot get the files on it to open on my powerbook. I have downloaded Windows Media Player for Mac and Stuffit Expander for Mac, but still no luck. I cannot get my computer to give m