Manish > -----Original Message----- > From: manish [mailto:[EMAIL PROTECTED]] > Sent: 04 June 2002 10:08 > To: [EMAIL PROTECTED] > Subject: How to upload a file??? > > > Hello All, > How can I upload a file from browser to server using cocoon. > I am using the following syntax... > <form name = "test" ENCTYPE="multipart/form-data" >
There's an example bundled with cocoon, on my tomcat installation it's at http://localhost:8080/cocoon/xsp/upload (cocoon version 2.0.1) It uses an xsp page which follows. NB, the bit where it 'contextualizes' is basically to get the upload directory name from web.xml - you may not need this, nor may you need the logging it does, but it's there to show you how . ============================= <?xml version="1.0" encoding="ISO-8859-1"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:xsp-request="http://apache.org/xsp/request/2.0" xmlns:xsp-response="http://apache.org/xsp/response/2.0" xmlns:log="http://apache.org/xsp/log/2.0" > <xsp:structure> <xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</xsp:i nclude> <xsp:include>org.apache.avalon.framework.context.ContextException</xsp:inclu de> </xsp:structure> <xsp:logic> File uploadDir = null; /** Contextualize this class */ public void contextualize(Context context) throws ContextException { uploadDir = (File) context.get(Constants.CONTEXT_UPLOAD_DIR); } </xsp:logic> <page> <title>This form allows you upload files</title> <content> <para> <form method="post" enctype="multipart/form-data" action="upload"> File: <input type="file" name="uploaded_file" size="50" /> <p><input type="submit" value="Upload File" /></p> </form> </para> <para> <ul> <xsp:logic> getLogger().debug("Dir=" + uploadDir); String[] filelist = uploadDir.list(); <![CDATA[ getLogger().debug("List=" + filelist.length); for (int i = 0; i < filelist.length; i++) { getLogger().debug("File [" + i + "]=" + filelist[i]); ]]> <li> <xsp:expr>filelist[i]</xsp:expr> </li> <![CDATA[ } ]]> </xsp:logic> </ul> </para> <para>Brought to you by Cocoon at <xsp:expr>new Date()</xsp:expr>.</para> </content> </page> </xsp:page> ============================= > > please let me know how to include this tag on cocoon side to accept file > type data > > from > anurag > > > --------------------------------------------------------------------- > Please check that your question has not already been answered in the > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html> > > To unsubscribe, e-mail: <[EMAIL PROTECTED]> > For additional commands, e-mail: <[EMAIL PROTECTED]> > > --------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faqs.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>