Creating avatar/background photo preview in custom members

I am in the process of building a custom members area for my website, and I am wondering how to enable members to select and preview their avatar or background photos. I would like to provide users with the ability to either save or discard the changes, similar to the functionality available in the Wix Members App.
I am using Editor X, and I have tried creating an upload button and connecting it to the dataset. However, I am struggling to implement the preview action before uploading the image.
If anyone has any suggestions or guidance on how to achieve this functionality, it would be greatly appreciated.
Thank you for your time and assistance.