0

I am trying to pass multiple files uploaded using the lightning-file-upload component to an apex class and access the uploaded files in apex.

My apex method is as follows:

public static Boolean tagUploaded(Object files){

   List<Id> documentIds;

   System.debug('files ========= '+files); 
}

I am trying to access the list of documentIds uploaded using the lightning-file-upload component.

Could someone help me retrieve the Ids from the files parameter that is passed to the apex method?

1
  • Can you add the JS code for the LWC. – samdev Mar 31 '20 at 3:20
0

You can use the event handler "onuploadfinished"

Just set this attribute in the lightning file upload element:

onuploadfinished={handleUploadFinished}

And then the JS function:

handleUploadFinished(event) { const uploadedFiles = event.detail.files; }

Documentation: https://developer.salesforce.com/docs/component-library/bundle/lightning-file-upload/documentation

Then you can call the apex passing the files as parameters, if you find any issue with this, you may can pass it as serialized JSON and parse it in the apex controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.