An efficient way to implement it: compute the checksum (for instance, MD5) of every photo uploaded, store the checksums in a database, compare the checksum of the next uploaded photo with all the checksums already in the database, if there is a match then this photo has been uploaded already.