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
Sam SwannSam Swann 

File Upload to a Standard Object in a Lightning Component

Hi

I am very new to Lightning Development. I am trying to learning developing Lightning components on my own.
I was trying to develop an Input form for Case Object. Now, I wanted to Attach files feature as well to the form at the very bottom.
Once I upload and save the form, a new Case record should be created with attachments in the record detail page.

I have used this to get the Input for upload a file:
 

<lightning:input type="file" label="Attachment" name="file" multiple="true" aura:id = "upButton" accept="image/png, .zip" onchange="{! c.handleFilesChange }"/>
 

Can someone share a simple code for the controller(handleFilesChange) as well as the Server-side class to save the data to Case object.

Thanks!

Manish Jha(Salesforce)Manish Jha(Salesforce)
Hi Sam,/Amit

You can consider using lightning:fileUpload component. You can upload files up to 2GB and attach it to the record at same time.

Please refer to https://developer.salesforce.com/docs/atlas.en-us.210.0.lightning.meta/lightning/aura_compref_lightning_fileUpload.htm for more details.

Thanks,
Manish Jha
 
kanchan baghelkanchan baghel
Manish, it worked for you??
 
sfdcMonkey.comsfdcMonkey.com
Check it out 
http://www.sfdcmonkey.com/2017/09/25/file-upload-lightning-component/
Thanks 
Nagendra Babu LakkimsettiNagendra Babu Lakkimsetti
Hi,
Iam new for Aura components. I created a form  on Aura Component using fileupload....
How to store the uploaded file into custom object record?User-added image