<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Dynamic amount of fileuploads: file not uploading</title><link>https://answers.axonivy.com/questions/273/dynamic-amount-of-fileuploads-file-not-uploading</link><description>&lt;p&gt;I'd like to give the user the ability to choose the amount of attachments he'd like to provide. To do this I created a datatable with buttons to add and remove attachment-lines:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;p:dataTable id="attachments" var="attachment" value="#{data.attachments}"&amp;gt;
    &amp;lt;p:column headerText="#{ivy.cms.co('/labels/vendor')}"&amp;gt;&amp;lt;p:inputText value="#{attachment.vendor}" /&amp;gt;&amp;lt;/p:column&amp;gt;
    &amp;lt;p:column headerText="#{ivy.cms.co('/labels/description')}"&amp;gt;&amp;lt;p:inputText value="#{attachment.description}" /&amp;gt;&amp;lt;/p:column&amp;gt;
    &amp;lt;p:column headerText="#{ivy.cms.co('/labels/amount')}"&amp;gt;&amp;lt;p:inputText value="#{attachment.amount}" /&amp;gt;&amp;lt;/p:column&amp;gt;
    &amp;lt;p:column headerText="#{ivy.cms.co('/labels/attachment')}"&amp;gt;&amp;lt;p:fileUpload value="#{attachment.file}" mode="simple" /&amp;gt;&amp;lt;/p:column&amp;gt;
    &amp;lt;p:column headerText=""&amp;gt;&amp;lt;p:commandButton value="delete-row" update="attachments" action="#{logic.deleteAttachment(attachment)}" /&amp;gt;&amp;lt;p:commandButton value="add-row"  update="attachments" action="#{logic.addAttachment()}" /&amp;gt; &amp;lt;/p:column&amp;gt;
&amp;lt;/p:dataTable&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The only problem is, that it seems to not upload the specified file. The submitted form is beeing processed by this script, the output of &lt;strong&gt;in.test&lt;/strong&gt; beeing &lt;strong&gt;false&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for(Integer i = 0; i &amp;lt; in.attachments.size(); i++) {
    in.test = in.attachments.get(i).file.exists().toString();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The Simple-Fileupload-Demo works, so I guess it can't be a problem with my installation / computer. I just cleared all of the attachments and uploaded only one. So while this is a foor loop, it just iterates through 1 time. Data is stored in my own Data Class &lt;strong&gt;Attachment&lt;/strong&gt;, containing 4 attributes (Vendor, Description, Amount and File).&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/273/dynamic-amount-of-fileuploads-file-not-uploading" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 24 Jan 2014 16:48:03 -0500</lastBuildDate><item><title>Answer by Flavio Sadeghi</title><link>https://answers.axonivy.com/questions/273/dynamic-amount-of-fileuploads-file-not-uploading/502</link><description>&lt;p&gt;To upload a file, the form-tag requires the correct enctype-type.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;h:form enctype="multipart/form-data"&amp;gt;
  ...
&amp;lt;/h:form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See also the example project which is delivered within Xpert.ivy Designer. It contains several file-upload demos. The location of the demo project is: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[Designer]/applications/samples/HtmlDialogDemos
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Flavio Sadeghi</dc:creator><pubDate>Fri, 24 Jan 2014 16:48:03 -0500</pubDate><guid>https://answers.axonivy.com/questions/273/dynamic-amount-of-fileuploads-file-not-uploading/502</guid></item></channel></rss>