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
Spencer Porter 9Spencer Porter 9 

Lightning Web Components - Use file-upload component on home page

I am trying to build a component which would allow users to upload a .csv file and then have additional logic to handle the contents of the file. I am trying to use LWC but it needs to be associated with a record, so it is only working on record pages. I followed the examples in the documentation here: https://developer.salesforce.com/docs/component-library/bundle/lightning-file-upload/documentation

Is there a way around this to allow it to work as a component on the home page?
Best Answer chosen by Spencer Porter 9
Deepali KulshresthaDeepali Kulshrestha
Hi Spencer,

Greetings to you!
You cannot use lightning-file-upload without RecordId because it only works when you provide Record Id. So if you want to use it on the home page then you have to provide record id to achieve this you can give a hardcoded id of any record. 
 
<lightning-file-upload 
label="Attach receipt" 
name="fileUploader" 
accept={acceptedFormats} 
record-id={myRecordId}  //record-id="1mIIjVv06OHa1piZmgeMPc"
onuploadfinished={handleUploadFinished} 
multiple>
</lightning-file-upload>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com