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 { %> <form action="" enctype="multipart/form-data" method="post"> <table border="0"> <tr> <td>Submitter:</td><td><input type="text" name="submitter" /></td> </tr><tr> <td>File:</td><td><input type="file" name="file" /></td> </tr><tr> <td colspan="2" align="center"> <input type="submit" /> </td> </tr> </table> </form> <% } %> 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: > <form action="/xwiki/bin/view/MySpace/Upload" > enctype="multipart/form-data" method="post"> > <input type="file" name="filepath" value="" size="40" /> > <input type="submit" value="Save" /> > </form> > 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@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 _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users