cocoon-users-fr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Hertz <danielhe...@shaw.ca>
Subject Problème avec Flowscript et renameTo()
Date Sun, 04 Dec 2005 22:30:46 GMT
Bonjour,

J'ai une problème se déplacer l'image avec ce Flowscript. Je m'excuse, 
mais, je ne connais pas beaucoup de Java nis Javascript. Merci pour 
votre aide!

Daniel

== Mon flowscript (la base est samples/forms/flow/upload_example.js) ==


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

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 uploadWidget = form.lookupWidget("upload");
 if (uploadWidget.getValue() != null) {
   var stream = uploadWidget.getValue().getInputStream();
   var reader = new java.io.BufferedReader(new 
java.io.InputStreamReader(stream));
   var line;
   while ((line=reader.readLine())!=null)
     buf.append(line).append("\n");
     // File (or directory) to be moved
   var f = new java.io.File(new java.io.File(reader));
     // Destination directory
   var dir = new java.io.File(new java.io.File("C:/Uploads/NewDirectory"));
     // Move file to new directory
   var success = f.renameTo(new java.io.File(dir, f.getName()));
   if (!success) {
       // File was not moved
   }
   reader.close();
     }
   return buf.toString();

     }

---------------------------------------------------------------------
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