Upload Files in Lightning Component

Vijay Kumar
2 min readJul 27, 2020
UploadUpload Files in Lightning Component

Hey guys, In this post we are going to learn about how to upload files in Salesforce lightning component.

In this example we will attached the files from Custom sObject by help of wrapper apex class in lightning component.

Files we used in this post example:-

uploadAttachmentCmp.cmp

Lightning Component

It is used to user interface display upload button and toast success message on browser.

uploadAttachmentCmpConroller.js

JavaScript Controller File

It is used for client side javascript function that is communicate to apex class method.

uploadFileController.apxc

Apex Class Controller

Upload the file into database server

Custom Object:- childObjTrigger__c

Custom Object

Upload the attachment files on custom sObject Files & Attechment section.

Final Output

Other post that would you like to learn

Note:- Custom sObject >> childObjTrigger__c

You need to change custom sObject name with your custom sObject name.

Step 1:- Create Lightning Component : uploadAttachmentCmp.cmp

From Developer Console >> File >> New >> Lightning Component

uploadAttachmentCmp.cmp [Lightning Component File]

Step 2:- Create Lightning Component : uploadAttachmentCmpController.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller

uploadAttachmentCmpController.js [JavaScript Controller]

Step 3:- Create Lightning Application : uploadFileController.apxc

From Developer Console >> File >> New >> Apex Class

uploadFileController.apxc [Apex Class Controller]

Originally published at https://www.w3web.net on July 27, 2020.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response