Posts

Showing posts from January, 2024

Custom File Upload to Salesforce using LWC and Apex

Hi Everyone, In this blog, we'll explore custom way of uploading a file to salesforce using Apex and lightning-input tag.  A file can be uploaded using either lightning-file-upload component or lightning-input (having type attribute as "file") component. Only difference between lightning-file-upload and lightning-input with type as 'file' is that files uploaded by using file-upload component directly get attached to records without writing any additional apex code, whereas you need to write Apex code for attaching files to record while using lightning-input component. Some important points Multiple files can be uploaded by having multiple attribute in component definition. All types of files are accepted and furthermore you can restrict what kind of file you want to upload by specifying valid file formats in accept attribute. Ex:- [".pdf", ".doc", ".jpg"] Uploaded files can be associated to a record by specifying record-id attri