Welcome Guest, Not a member yet? Register   Sign In
How to avoid duplicate uploaded file?
#1

[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
android1.jpg
android2.jpg
android3.jpg
and so on...

How to avoid this duplicate files but instead just replace the
existing the same file with new file?

Thanks in advanced.




#2

[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
#3

[eluser]LuckyFella73[/eluser]
According to the userguide you need that config item:
Code:
$config['overwrite'] = TRUE;




Theme © iAndrew 2016 - Forum software by © MyBB