From ludovic@xwiki.org Thu Feb 28 13:15:07 2008 From: Ludovic Dubost To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] Cannot use FileUploadPlugin !? Date: Thu, 28 Feb 2008 13:15:04 +0100 Message-ID: <47C6A5C8.1040609@xwiki.org> In-Reply-To: <81827c930802271819x57cfeb22kbd37029ee8760d94@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3577982169888810673==" --===============3577982169888810673== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Which version of XWiki are you using ? There is some issue that makes some code empty the file upload list. Can you try by posting to a page with that in the URL ?xpage=plain Also you should be able to do this without going to the internal API. There is addAttachment in Document Here is a test code that shows the file upload plugin in action to show that you get data: 1 File Upload Snipplet <% if (request.get("submitter")!=null) { def fupl= xwiki.get("fileupload"); println fupl; def myfiles = fupl.getFileItems(); println "{pre}" println myfiles; println "{/pre}" println fupl.getFileName("file") } else { %>
Submitter:
File:
<% } %> Ngo Thi Hong Nga wrote: > Hi, I want to create a page allowed to upload more files together > using FileUploadPlugin. I created 2 documents but the FileUploadPlugin > seems not work, the data return is null and the document > MySpace.Upload is attached with a file 0KB. Anyone can explain me why > this happens ? And how to fix ? > > 1. MySpace.doc: >
enctype="multipart/form-data" method="post"> > > >
> 2. MySpace.Upload > <% > import com.xpn.xwiki.plugin.fileupload.FileUploadPlugin; > import com.xpn.xwiki.doc.XWikiDocument; > import com.xpn.xwiki.doc.XWikiAttachment; > > print "Start upload... "; > def docu=doc.getDocument(); > FileUploadPlugin fileupload = (FileUploadPlugin) > context.getContext().get("fileuploadplugin"); > byte[] data = fileupload.getFileItemData("filepath", context.getContext()); > def filename = "myfile"; > def attachment = docu.getAttachment(filename); > > print data; > if (!attachment) { > attachment = new XWikiAttachment(docu, filename); > docu.getAttachmentList().add(attachment); > } > attachment.setContent(data); > docu.saveAttachmentContent(attachment, context.getContext()); > doc.save() > > println "done" > %> > _______________________________________________ > users mailing list > users(a)xwiki.org > http://lists.xwiki.org/mailman/listinfo/users > > -- Ludovic Dubost Blog: http://blog.ludovic.org/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost --===============3577982169888810673==--