After thorough reading other post having the similar issues, I have found out the proper way to upload the files and update the database.
Follow the sequence…
First upload the image then get the id
Update the data with the image id
It will work perfectly.