Skip to main content Tableau Conference is happening now. Tune in to activate your data superpowers with Tableau and Agentforce. Watch live on SF+ for exclusive digital content, new product demos, and key insights for data and analytics lovers.
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
2 answers
  1. Feb 26, 2018, 1:50 PM
    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
0/9000