cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roman Hrivik" <>
Subject RE: Uploading files with Cocoon 2.1 (one more)
Date Thu, 27 Nov 2003 16:12:00 GMT

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

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 

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"

  <!-- for relative path use -->
    <map:parameter name="overwrite-file" 

<!-- 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-form-field-prefix#number#uploadedFileName - file name if was



-----Původní zpráva-----
Od: Josep Riudavets [] 
Odesláno: 27. novembra 2003 16:06
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()){

//code for uploading and saving a file


That generates the next problem: if you upload a file, a folder is
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
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()),
code is only executed first time .. because second time the folder

Am I wrong???

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message