Notes
<template>
<lightning-card>
<!-- File Upload Component -->
<lightning-file-upload
label="Upload Files"
name="fileUploader"
accept=".pdf,.png,.jpg"
record-id={recordId}
onuploadfinished={handleUploadFinished}>
</lightning-file-upload>
<!-- Display uploaded files -->
<template if:true={uploadedFiles}>
<ul>
<template for:each={uploadedFiles} for:item="file">
<li key={file.documentId}>
{file.name} (ID: {file.documentId})
</li>
</template>
</ul>
</template>
</lightning-card>
</template>
JavaScript
import { LightningElement, api } from 'lwc';
export default class FileUploadComponent extends LightningElement {
@api recordId;
uploadedFiles;
handleUploadFinished(event) {
const uploadedFiles = event.detail.files;
console.log('Uploaded Files', uploadedFiles);
this.uploadedFiles = uploadedFiles.map(file => ({
name: file.name,
documentId: file.documentId
}));
}
}