I wrote my own action and it works correctly, you can use it.
See attached fileuploadsample.zip


You will specify those parameters to action
number-of-files - number of uploaded files - number of input file fields
file-form-field-prefix - form field prefix for file field i.e. "myFile"
                                the file field names must be always be
                                myFile1, myFile2, myFile3, ...
upload-directory - relative or physical path where to save file
overwrite-file - it can be deny, allow, rename


In your sitemap you will put 
  <map:actions>
   <map:action 
        logger="sitemap.action.fileupload" 
        name="file-upload-action" 
        src="com.mypackage.FileUploadAction"/>
  </map:actions>

than use i.e.

<map:match pattern="doupload">
  <map:act type="file-upload-action">
     <map:parameter name="number-of-files" value="3"/>
     <map:parameter name="file-form-field-prefix" value="myfile"/>
     <!-- for physical path use
          <map:parameter name="upload-directory"
value="C:\upload\test1"/>
        -->

  <!-- for relative path use -->
    <map:parameter 
        name="upload-directory" 
        value="/WEB-INF/myupload/test1"/>
    <map:parameter name="overwrite-file" 
                         value="rename"/>
                        


<!-- action will return 
   file-form-field-prefix#number#renamed  true / false
   file-form-field-prefix#number#uploaded  true / false
   file-form-field-prefix#number#originalFileName - as was in request
   file-form-field-prefix#number#physicalFilePath - full path to saved
file
   file-form-field-prefix#number#uploadedFileName - file name if was
renamed
-->


........

Roman






-----Původní zpráva-----
Od: Josep Riudavets [mailto:[EMAIL PROTECTED] 
Odesláno: 27. novembra 2003 16:06
Komu: [EMAIL PROTECTED]
Předmět: Fw: Uploading files with Cocoon 2.1 (one more)

Hi all ...

Geoff... thanks for your help all these days, and for your interest
about my
problems for uploading files in Cocoon 2.1.

Steven ... thanks for posting your upload action. It's very important to
colaborate in this way, sharing the knowledges we have.

About your upload action, I think it contains an error, that causes you
can't upload a file if there have been uploaded another file before....

Here's the code of your upload action:

....


File folder = new File (uploadfolder);
if (!folder.exists()){

folder.mkdirs();
//code for uploading and saving a file

}

That generates the next problem: if you upload a file, a folder is
created,
and the file is saved into this folder. If you want to upload a second
file,the folder is already created, and !folder.exists() is false , and
no
code is executed in order to upload and save the file.

I have used next if condition:

if (true) {
...
}

In this way, the code inside the "if condition" is always executed, and
files are saved without problem. If you mantain if(!folder.exists()),
the
code is only executed first time .. because second time the folder
already
exists.

Am I wrong???



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Attachment: fileuploadsample.zip
Description: Zip compressed data

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to