How to avoid duplicate uploaded file? |
[eluser]solid9[/eluser]
Hi guys I want to avoid duplicate uploaded file names. But what CI did was it duplicate the name and extended the name with numbers like this below, Code: android.jpg How to avoid this duplicate files but instead just replace the existing the same file with new file? Thanks in advanced.
[eluser]Abel A.[/eluser]
Get the hash value of the file and compare it to other hashes. Each file has a unique hash and if they're identical files, then they will have the same hash value. It is not optimal to check every single file's hash value from the hdd, but instead have the hash values stored in the database. Use md5 to get the hash value. http://php.net/manual/en/function.hash-file.php
[eluser]LuckyFella73[/eluser]
According to the userguide you need that config item: Code: $config['overwrite'] = TRUE; |
Welcome Guest, Not a member yet? Register Sign In |