Upload files in lightning component by w3web.net

Upload 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:-

File Name File Type Description
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

file upload in lightning component -- w3web.net

Other related post that would you like to learn in lightning component.

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]

Further post that would you like to learn in lightning component.

Hi, This is Vijay behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time.

6 thoughts on “Upload Files in Lightning Component”

Leave a Comment