cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <DHo...@csir.co.za>
Subject Upgrading the "Upload File" sample to handle binary formats
Date Thu, 02 Sep 2004 06:24:07 GMT
I am sure this is an easy task for someone
who knows what they are doing (i.e. not me) 

In the "Upload File" sample, only text is handled
and the code looks like:

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");
    reader.close();
  }
  return buf.toString();
}

It seems it should be possible to upgrade this to 
write out binary...???  Specifically, I want users to
be able to upload standard image files - JPEG, GIF
and PNG (and maybe BMP).   The ideal solution would
only allow these files types, but this is less critical than
simply being able to get binary uploaded in the first 
place.

Any help appreciated... if the solution works, maybe
I can post it to the Wiki for future reference.

Thanks
Derek

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message