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
User SethUser Seth 

How to get the original url of a Image Uploaded

I have one LWC can be used to upload a Image and display the image
 
HTML:
<template>
    <input type="file"  name="image" id="file"  onchange={loadFile} style="display: none;">
    <label for="file" style="cursor: pointer;">Upload</label>
    <img id="output" width="200" />
</template>
 
JS:
loadFile(event) {
    var image = this.template.querySelector('img');
    image.src = URL.createObjectURL(event.target.files[0]);
    console.log(image.src);
    console.log(image);
    }
 
This is giving temporary url of the image uploaded.
This url I am getting in the console is not working when I put that in Image Src tag in a separate LWC component.

How to get the original image url uploaded.
So that I can store this url in Custom field and show the image based on that url in that field. when any new image uploaded I will change url in the custom field and show new image based on that irl in that Custom Field(URL).
Shri RajShri Raj
When you upload a file to Salesforce, the file is stored in Salesforce's file storage and you are given a unique URL for accessing the file. You can get the original URL of the uploaded file by using the ContentDocumentLink object to retrieve the URL associated with the uploaded file. You can store this URL in a custom field on the record that you want to associate the file with, such as an Account, Contact or Custom Object. To do this, you need to perform the following steps:
Create a custom field in the record to store the file's URL.
When you upload the file, use the ContentVersion object to create a new version of the file and get the associated ContentDocumentId
Use the ContentDocumentLink object to create a new link between the ContentDocumentId and the record, and set the visibility to "All".
Get the URL of the file using the ContentDocumentLink object and store it in the custom field.