I have written a script to upload an image to a particular portion of my site.
What kind of check do I need to do to detect if a duplicate entry is trying to be uploaded through the form?
Example:
One user submits firefoxlogo.jpg.
Another user a few days later tries submitting firefox.jpg which is the same image, just renamed.
The same as “the binary data is identical” or “the image looks similar”? In the first case, you can calculate the hash of a file using
sha1_file(for SHA1 hashes). You should never rely on the filename for checking whether files are unique or not. E.g. one user could upload “firefox.png” containing the browser’s logo and someone else a screenshot of it. The hash has a fixed length (40 for SHA1) which is another advantage over using filenames.