Upload files in lightning component by w3web.net

Upload Files in Lightning Component | how to upload file dynamically using the wrapper class in Salesforce

1,000 views

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 Salesforce

 

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 Salesforce

 

 

 

FAQ (Frequently Asked Questions)

How do I upload files to Salesforce?

Enable the preference to upload files as Salesforce Files in Salesforce Classic in Setup. Type Salesforce Files in the Quick Find box, select General Settings, and then click Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments.

How do you display an image from static resources in the lightning component?

We can use $Resource. resourceName within an expression. resourceName is the Name of the static resource.

What is ParentId in Attachment Salesforce?

A ParentId is the 18-character Salesforcer Id of the record that the attachment belongs to. To get started creating and updating attachments, first, load the {salesforcer} and {dplyr} packages and login, if needed.

Related Topics | You May Also Like

  • Your reaction of the article ▾
 

Hi, This is Vijay Kumar 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. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

8 thoughts on “Upload Files in Lightning Component | how to upload file dynamically using the wrapper class in Salesforce”

Leave a Comment