function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raghu Natha 2Raghu Natha 2 

How to Send the uploaded file to Apex using lightning:fileUpload

Component Code
<lightning:fileUpload label="Upload Multiple files" 
                               multiple="false" 
                              accept=".pdf, .png, .jpg"
                              recordId="{!v.recordId}"
                              aura:id="multipleUpload"
                             onuploadfinished="{!c.handleUploadFinished}" />

JScontroller
({
    handleUploadFinished: function (component, event, helper) {
        // Get the list of uploaded files
        var uploadedFiles = event.getParam("files");
alert("Files uploaded length  : " + uploadedFiles.length);
      }    
})

After the Alert How do we retrieve the files uploaded and send it to Apex class ?
Also on the APEX class what is the input parameter type we use for receiving the file sent from the above JS
Naveen PoojaryNaveen Poojary
Hi Raghu,
Please refer below link it may help you in this regard.
https://teamforcesite.wordpress.com/2017/11/07/winter-18-uploading-files-in-lightning-component/
NagendraNagendra (Salesforce Developers) 
Hi Raghu,

Please review the documentation: The lightning file upload component, uploads files and attaches it to a record.

You specify the record to attach the files to with the below attribute:

recordId => String => The record Id of the record that the uploaded file is associated to.

If you want to validate the files or have some logic to execute on them, use the below callback function provided:

onuploadfinished => Action => The action triggered when files have finished uploading.

The docs show this example of a callback function:
({ handleUploadFinished: function (cmp, event) { // Get the list of uploaded files var uploadedFiles = event.getParam("files"); alert("Files uploaded : " + uploadedFiles.length); } })
As you can see the function receives an event called files that can be inspected.

Thanks,
Nagendra