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:
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.
Best Answer
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:
and Home page:
eventhough i have a default recordId as you do.