function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nida Khan 5Nida Khan 5 

Urgernt help: Uploading Multiple files at Amazon Server

Hello All,

I have a requirement to upload multiple files at a same time at the amazon server. Has anyone faced such issue once and can help on the same.

Vijay NagarathinamVijay Nagarathinam
Hi Nida,

Please use the below code for multiple attachement.
<apex:page controller="UploadAttachmentController" >
<apex:sectionHeader title="Attach File to {!resIns.Name}" />
<apex:form >
<apex:PageBlock >
<apex:pageMessages />

<apex:pageBlockSection columns="1" id="ttt">
<apex:outputlabel ><b>1.Select the file to upload</b></apex:outputLabel>
<apex:outputlabel >Type the path of the file or click the Browse button to find the file.</apex:outputlabel> 
<apex:inputFile id="file_File" value="{!att.body}" filename="{!}"/>
<apex:outputlabel ><b>2.Click the "Attach File" button.</b></apex:outputLabel>
<apex:outputlabel >Repeat steps 1 and 2 to attach multiple files.</apex:outputlabel>
<apex:outputlabel >( When the upload is complete the file information will appear below. )</apex:outputlabel>
<apex:commandButton id="uploadBtn" value="Attach File" action="{!uploadAttachment}"/>
<apex:pageBlockSection columns="1">
<apex:outputlabel ><b>3. Click the Done button to return to the previous page.</b></apex:outputLabel>
<apex:outputlabel >( This will cancel an in-progress upload.)</apex:outputlabel> 
<apex:commandButton id="uploadBttn" value="Done" action="{!Done}"/>

<apex:pageBlockSection title="You have uploaded the file" rendered="{!show}" columns="1">
<apex:pageBlockSectionItem >
File Name :- <apex:outputText value="{!savedAttName}"></apex:outputText>
<apex:pageBlockSectionItem >
File Size :- <apex:outputText value="{!savedAttSize}"></apex:outputText>
public class UploadAttachmentController {
Public id conId{get;set;}
public Attachment att{Get;set;}
public boolean show{get;set;}
public string size{get;set;} 
public string savedAttName{get;set;}
public double savedAttSize {get;set;}
public RestorationDocument__c resIns {get;set;}

public UploadAttachmentController() { 
string idValue = ''; 
conId = ApexPages.currentPage().getParameters().get('id'); 
resIns = [SELECT id,Name from RestorationDocument__c where Id =: conId];
if(ApexPages.currentPage().getParameters().get('otherIds') != null){
idValue = ApexPages.currentPage().getParameters().get('otherIds');
show = true;
if(idValue != ''){ 
for(Attachment att : [select id, body, name from attachment where id =: idValue])
savedAttName =;
savedAttSize = att.body.size();
if(att == null){
att = new Attachment();

public pageReference uploadAttachment(){
List<Attachment> attList = new List<Attachment>();
att.IsPrivate = true;
att.parentId = conId;
if(att.body != null)
if(attList.size() > 0){
Insert attList ; 
pageReference pgRe = new pageReference('/apex/UploadAttachmentPage?id='+conId+'&otherIds='+att.Id);
return pgRe;
}else {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select the File'));
return null;

public PageReference Done(){ 
PageReference pageRef = new PageReference('/'+conId);
return pageRef; 

Nida Khan 5Nida Khan 5
Hello Vijay,

Thanks for your response.
I need a code that can upload mulitple files at the same time, like we usually do in gmail by pressing CTRL button and then hit save.