Answer the question
In order to leave comments, you need to log in
How to protect against duplication of files when uploading to the server?
What is the best way to save files on the server?
Previously, I wrote down an md5 hash for each file and, when uploading, I checked the hash of the new file with the one in the database, and if such a hash exists, the file was not uploaded, but the id of the previous uploaded file was given.
But, as I understand it, there is a high probability of a collision with md5. What is the best way to check files for duplicates then?
Answer the question
In order to leave comments, you need to log in
1) Store several different hashes, there are other algorithms besides md5
2) Before md5, also compare just the size
3) If EVERYTHING matches - for a complete exception - compare byte by byte
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question