A simple yet sloppy fix would be to have your script create a .txt file, named the same as you upload file. Since it is created at time of upload have your script check the $mtime of the txt file and if it is 30 days old delete filename.*
I like the hash answer much better, though.