+ Start a Discussion
Raghavendra ARaghavendra A 

Image Upload and Show in Lightning Component

Hi,

I would like to develop a Lightning component that allws the user to upload image or images and then show the uploaded image in the area that the image was loaded. Any help or direction with this kind of lightning is highly appreciated. 

Thanks,
Raghu
Narender Singh(Nads)Narender Singh(Nads)
Hi Raghav,

Follow this link: http://sfdcmonkey.com/2017/09/25/file-upload-lightning-component/
You will get an idea of how to do it

Let me know if it helps.
Thanks
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Hi Raghavendra,

Did you try using lightning:fileUpload (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_fileUpload.htm) and lightning:fileCard (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_fileCard.htm) to upload and display the file uploaded in your lightning component?

Thanks,
Ashwin
Raghavendra ARaghavendra A
Hi Ashwin,

Thanks for responding. Do we need to store the Image uploaded in Documents or attach to Records before we the image using the fileCard component?

Thanks,
Raghu
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Hi Raghu,

Yes the image/file will get automatically uploaded to the contectDocument which you will be able to view in the relatedlist in notes&attachement or files of the recordId you set in the fileUpload component
recordId="{!v.myRecordId}"
and yes again the file card will be based on the fileId(ContentDocument Id) passed in 
<lightning:fileCard fileId="069XXXXXXXXXXXX"/>

Thanks,
Ashwin