0

I am using the LWC file upload and it works fine on other objects but fails on the opportunity Line Item.It just states that it can not upload the image and throws no errors in the chrome console or the dev console. below is the code I use.

ImageUpload.js

import {LightningElement, api} from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
export default class ImageUpload extends LightningElement {
    @api recordId;
    get acceptedFormats() {
        return ['.png','.jpg','.jpeg'];
    }
    handleUploadFinished(event) {
        // Get the list of uploaded files
        const uploadedFiles = event.detail.files;
        let uploadedFileNames = '';
        for(let i = 0; i < uploadedFiles.length; i++) {
            uploadedFileNames += uploadedFiles[i].name + ', ';
        }
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success',
                message: uploadedFiles.length + ' Files uploaded Successfully: ' + uploadedFileNames,
                variant: 'success',
            }),
        );
        //this.dispatchEvent(new CustomEvent('uploaded'));
    }
}

ImageUpload.html

<template>
    <lightning-card title="Upload Photos" icon-name="custom:custom19">
        <lightning-file-upload
                name="fileUploader"
                accept={acceptedFormats}
                record-id={recordId}
                onuploadfinished={handleUploadFinished}
                multiple>
        </lightning-file-upload>
    </lightning-card>
</template>
2
  • Could be a sharing issue? Does uploading the same exact file on a different object work? Oct 6, 2020 at 1:50
  • Yes uploading the same exact file on a different object works. I have found a workaround right now that includes creating a custom object before the file is uploaded and linking the file to it but I still want to figure this out so I do not have to create a object for every file uploaded. Oct 7, 2020 at 3:22

0

You must log in to answer this question.