Re: Flowscript - Move file to another directory

Peter Sparkes <[email protected]>
Newsgroups gmane.text.xml.cocoon.user
Message-ID <[email protected]>
Hi Robby,

Thank you very much, I spent several hours yesterday trying to find out how to do it without 
success. Thanks to you its now working.

What I am doing is upload multiple image files using the upload widget and then moving them to the 
required directory.

    function uploadprogress() {

         var form = new Form("forms/uploadprogress_model.xml");
         form.setAttribute("counter", new java.lang.Integer(0));
         var k = form.showForm("uploadprogress-display-pipeline.jx");

         var fileSource = "D:/cocoon-2.1.11-wl/build/webapp/upload-dir/";     //for testing
         var fileTarget = "D:/cocoon-2.1.11-wl/build/webapp/resources/imagesSmall/";     //for testing

         var fileSourcePath = "";
         var fileTargetPath = "";
         var file = "";

         k.invalidate(); // do not allow return to the form

             var files = [];
             var repeater = form.getChild("uploads");
             for (var i = 0; i < repeater.getSize(); i++) {
                 var upload = repeater.getRow(i).getChild("upload");
                 files[i] = {
                     filename: upload.value.fileName,
                     bytes: upload.value.size
                 };
                fileSourcePath = fileSource + upload.value.fileName;
                fileTargetPath = fileTarget + upload.value.fileName;
                file = new File(fileSourcePath);
                file.renameTo(new File(fileTargetPath));
             }
         cocoon.sendPage("upload-images-success.jx",
             {
                 files: files
             }
         );
    }

Peter


On 01/01/2013 21:18, Robby Pelssers wrote:
> http://stackoverflow.com/questions/4645242/how-to-move-file-from-one-location-to-another-location-in-java
>
> The easiest is to use apache commons IO.  But you can also use the rename strategy but you will need to take care of a few things in that case.
>
> Robby
>
> -----Original Message-----
> From: Peter Sparkes [mailto:[email protected]]
> Sent: Tuesday, January 01, 2013 6:08 PM
> To:[email protected]
> Subject: Flowscript - Move file to another directory
>
> Hi,
>
> I am trying to copy image files from one directory to another, using flowscript, without any success.
>
> Please has anyone got an example
>
> java version "1.6.0_22"
>
> Thanks
>
> Peter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:[email protected]
> For additional commands, e-mail:[email protected]
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.