cocoon-users-fr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Hertz <danielhe...@shaw.ca>
Subject Re: Problème avec Flowscript et renameTo()
Date Thu, 08 Dec 2005 12:41:54 GMT
Sylvain Wallez wrote:
> Et si vous utilisez Cocoon 2.1.8:
>
>  uploadWidget.getValue().copyToFile("blah");
>
> Sylvain

Super-bon! Merci à tous pour vos suggestions et code!

J'ai fais:

importPackage(Packages.java.io);
importPackage(Packages.java.util);
importPackage(Packages.java.lang);

cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");

function upload() {
   
    var form = new Form("forms/upload_model.xml");
    var k = form.showForm("upload-display-pipeline");

    k.invalidate();

    cocoon.sendPage("upload-success-pipeline.jx",
        {
            uploadContent: handleUpload(form),
            // username: form.lookupWidget("user").getValue(),
            filename: 
form.lookupWidget("upload").getValue().getHeaders().get("filename")
        }
    );
}

function handleUpload(form) {
 
  var buf = new java.lang.StringBuffer();
  var baseDir = new java.io.File("C:/newdirectory");
  var userID = cocoon.session.getAttribute("userID");
  var newDir = new java.io.File(baseDir + java.io.File.separator + userID);
      
  var fileName = 
form.lookupWidget("upload").getValue().getHeaders().get("filename");
 
  var uploadWidget = form.lookupWidget("upload");
  if (uploadWidget.getValue() != null) {
     
      // test if new directory exists, if not, create it
       if (!newDir.exists()) {        
           newDir.mkdirs();
       }
    uploadWidget.getValue().copyToFile(newDir + java.io.File.separator + 
fileName);
   
    }
   
    }

Daniel

---------------------------------------------------------------------
Liste francophone Apache Cocoon -- http://cocoon.apache.org/fr/
Pour vous desinscrire : mailto:users-fr-unsubscribe@cocoon.apache.org
Autres commandes : mailto:users-fr-help@cocoon.apache.org


Mime
View raw message