Associated images

In a system where a user can choose images to upload, he can upload wrong images and then select others.

How do I create a link between the images and their recorded url registered in the database?

And how to delete images that have no connection with the records stored in the database.

Dirceu M. de Azevedo

Have solution?