Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 19741 invoked from network); 23 Jan 2004 07:39:06 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 23 Jan 2004 07:39:06 -0000 Received: (qmail 31030 invoked by uid 500); 23 Jan 2004 07:38:37 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 31008 invoked by uid 500); 23 Jan 2004 07:38:36 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 30995 invoked from network); 23 Jan 2004 07:38:36 -0000 Received: from unknown (HELO srv01.ezyreg.com) (69.57.142.83) by daedalus.apache.org with SMTP; 23 Jan 2004 07:38:36 -0000 Received: from lincslaptop (037.a.004.pth.iprimus.net.au [211.26.96.37]) (authenticated) by srv01.ezyreg.com (8.11.6/8.11.6) with ESMTP id i0N7dOl17764 for ; Fri, 23 Jan 2004 07:39:25 GMT Message-ID: <003d01c3e183$e9d01740$25601ad3@lincslaptop> From: "Lincoln" To: References: <5.2.0.9.2.20040122193327.00b14388@10.0.0.162> <4010C460.3070407@gmx.net> Subject: Re: File upload/Multipart form Date: Fri, 23 Jan 2004 15:28:39 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I am trying to use the put method in an xform to put a file on the server. As I am a newbie to forms and cocoon, should I be using your approach to get a file on the server? Linc Lincoln Mitchell hm: 618 9250 6772 mb: 0414 286 433 email: lincoln@linc.net.au web: www.linc.net.au ----- Original Message ----- From: "Stephan Coboos" To: Sent: Friday, January 23, 2004 2:51 PM Subject: Re: File upload/Multipart form > Lionel Crine wrote: > > > Here is a sample code : > > > > HttpServletRequest request = (HttpServletRequest) > > objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT); > > contentType = request.getContentType(); > > if (contentType == null) { > > contentType = parameters.getParameter("defaultContentType", null); > > } > > if (contentType == null) { > > throw new Exception("ERROR"); > > } else if (contentType.startsWith("application/x-www-form-urlencoded") > > || contentType.startsWith("multipart/form-data")) { > > String parameter = parameters.getParameter(FORM_NAME, null); > > if (parameter == null) { > > throw new Exception("ERROR"); > > } > > String sXml = request.getParameter(parameter); > > inputSource = new InputSource(new FileInputStream(sXml)); > > > > } else if (contentType.startsWith("text/plain") || > > contentType.startsWith("text/xml") || > > contentType.startsWith("application/xml")) { > > > > len = request.getContentLength(); > > if (len > 0) { > > PostInputStream anStream = new > > PostInputStream(request.getInputStream(), len); > > inputSource = new InputSource(anStream); > > } else { > > throw new SyspeoException("ERROR); > > } > > } else { > > throw new SyspeoException("ERROR); > > } > > > > InputStream is = inputSource.getByteStream(); > > > Hello Lionel, > > sorry, but I don't know why you use this complicated code to realize > uploads in cocoon. There is a solution which is very very easier! > > 1.) Set enable-uploads to true in web.xml. > 2.) Get the uploaded file with request.getAttribute("filename_on_the_form"); > 3.) After that you will receive an object of type PartOnDisk for > example. Use getFile() to receive the uploaded file. > > Thats it. Isn't it easy? > > More informations: > http://wiki.cocoondev.org/Wiki.jsp?page=FileUploadsWithCocoon2.1 > > Regards > Stephan > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org > For additional commands, e-mail: users-help@cocoon.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org