I've done something similar to this. Here's the theory behind...
SubFolders are your categories, upload your images into whatever subfolder. Create a script that reads each folder makes an array, and compares it to your XML/DB. in PHP you would do a create an array from your XML/DB of the images in that XML/DB then loop it through and compare it, in php could use.
If the file exists in the folder but not in your XML/DB it writes to it. Similarly if something exists in your XML/DB that doesn't exist in your Folders you remove it from the XML.
Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.