---------------------------------------------------------------------------------------------------------------------------------
VisualForce Code
---------------------------------------------------------------------------------------------------------------------------------
<apex:page standardController="Account" extensions="MultipleUploadController">
<apex:form>
<apex:pageBlock title="Upload Multiple Attachment to Object">
<apex:pageBlockButtons>
<apex:commandButton value="Upload" action="{!SaveAttachments}"/>
</apex:pageBlockButtons>
<apex:pageMessages id="MSG"/>
<apex:actionFunction name="ChangeCount" action="{!ChangeCount}"/>
<apex:pageblocksection>
<apex:pageBlockSectionItem>
<apex:outputLabel value="How many files you want to upload?"/>
<apex:selectList onchange="ChangeCount() ;" multiselect="false" size="1" value="{!FileCount}">
<apex:selectOption itemLabel="--None--" itemValue=""/>
<apex:selectOptions value="{!filesCountList}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageblocksection>
<apex:pageBlockSection title="Select Files" rendered="{!IF(FileCount != null && FileCount != '', true , false)}">
<apex:repeat value="{!allFileList}" var="AFL">
<apex:inputfile value="{!AFL.body}" filename="{!AFL.Name}" />
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
-------------------------------------------------------------------------------------------------------------------------------------------
Controller
-------------------------------------------------------------------------------------------------------------------------------------------