You need to sign in to do that
Don't have an account?
Rakesh keerthi 9
lightning file upload on button click
Hi,
I'm creating a lightning component to upload files. for this I'm using lightning:fileUpload .
But here in my case, I've got a button, when the button is clicked, I want to achieve the same functionality as lightning:fileUpload.
Currently this is what I'm trying out.
and js is
when i run this I get the error as fileUploader.click is not a function
please let me know on how can I get rid of that error and get that functionality.
Thanks
I'm creating a lightning component to upload files. for this I'm using lightning:fileUpload .
But here in my case, I've got a button, when the button is clicked, I want to achieve the same functionality as lightning:fileUpload.
Currently this is what I'm trying out.
<aura:component> <aura:attribute name="multiple" type="Boolean" default="false"/> <aura:attribute name="disabled" type="Boolean" default="false"/> <lightning:fileUpload aura:id="fUploader_1" name="fileUploader" label= "Demo Upload" multiple="{!v.multiple}" accept="{!v.accept}" disabled="{!v.disabled}" recordId="abcd" onuploadfinished="{!c.handleUploadFinished}"/> <lightning:button variant="Brand" label="Base" title="Base action" onclick="{!c.handleClick}"/> </aura:component>
and js is
({ handleUploadFinished: function (cmp, event) { // This will contain the List of File uploaded data and status var uploadedFiles = event.getParam("files"); console.log("Files uploaded : " + uploadedFiles.length); }, handleClick: function (cmp, event) { var fileUploader = cmp.find("fUploader_1"); fileUploader.click(); } })
when i run this I get the error as fileUploader.click is not a function
please let me know on how can I get rid of that error and get that functionality.
Thanks
Raj Vakati
There is no click event in the lightning:fileUpload .. I am not sure what is your requirerement .. if you need custom javasctipt events create a custom component from the scratch
Dipanshu Singh 7
Do you get answer?