This should now be working. In order for the code to get the image's URL the "Use the WordPress Media Library manager for image, video, audio, or file fields" setting must be enabled on your form.
The reason is that a URL for the image will need to be generated when it is uploaded and this needs to be done before the form has been submitted.
Thank you for your help.
Is there any way to make the snippet code works with default media library manager from toolset form instead of using WordPress Media Library manager?
We don't want to have all user to see all the media from another user.
Unfortunately no it isn't as the images need to be first uploaded before they can be picked up to be added as featured images.
If you have our Access plugin installed you can essentially moderate the media library so users will only have access to the images they upload and not see every other images in the library.