2

I'm trying to implement file upload functionality following the instructions in the documentation. But the uploader is being displayed as a disabled input.

<aura:component implements="forceCommunity:availableForAllPageTypes,force:hasRecordId">

<aura:attribute name="recordId" type="String" default="0031800000SEgfD" />
<lightning:fileUpload label="Attach receipt"        
                                  multiple="true"
                                  accept=".pdf, .png"
                                  recordId="{!v.recordId}"
                                  onuploadfinished="{!c.handleUploadFinished}" 
                                  disabled="false"/>
</aura:component>

Controller:

({
    handleUploadFinished: function (cmp, event) {
        alert('before upload');
        // Get the list of uploaded files
        var uploadedFiles = event.getParam("files");
        alert("Files uploaded : " + uploadedFiles.length);
    }
)}

Result:

enter image description here

As you can see, I explicitly tried to set the disabled to false hoping that changes something even though it is the default state.

Has anyone ran into this before? The documentation says this behavior is expected when used in Lightning Out or standalone apps only. There is a mention of file size limits in communities, which makes me think it should be working in communities.

2

You need to forcibly add the component to an Object record page, otherwise the ID will not bind to your component attribute, I had the same behavior a while back when implementing it. Note, the component whne using it with a community record page: enter image description here

and Home page:

enter image description here

eventhough i have a default recordId as you do.

5
  • This functionality is not a part of the object record page. It is embedded in a Build Your Own Community page. i'm grabbing the contact record id based on the logged in user.
    – Avinash
    Mar 30 '18 at 1:44
  • in my experience, you cant go about using the component anywhere in your community, hence my comment in regards to the record detail page
    – glls
    Mar 30 '18 at 2:03
  • I have developed a solution using lightning:input, but it can accept only up to 1 MB size files. The other option is to develop a VF page as it allows up to 10 MB and wrap it in a lightning component. I was hoping to overcome these limitations by using lightning:fileUpload. Are you aware of any other solutions?
    – Avinash
    Mar 30 '18 at 2:10
  • not that i am aware of
    – glls
    Mar 30 '18 at 2:22
  • It's a step backwards from apex for file uploads, frustrating but I imagine it will be fixed in a few years Jul 27 '18 at 17:28

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.