Hi @Thilina Tantirigama,
Thank you for posting in this community.Are you using the path to the file instead of the link to the file?
The path of the file changes because of the file's storage address or the renaming of the file, while the link to the file does not.
File Path:
File Link:
The link to the file is the unique encoding of the file on this site. As long as the file exists, the encoding will not change, even if the file is renamed or moved around the site.
For more information on copying links, you can refer to section Share by using "Copy link" in this article: Share SharePoint files or folders.
Hope this information is helpful to you.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.