The best option IMO would be to to use sha1_file It will create a unique hash based on the file contents. This would only collide if its the same image or a hash collision which is a 1 in 2^160 chance. You can avoid having duplicate images this way however because you are creating a hash from the file it can be slower.
$filename = sha1_file($upload_file) . $ext;
Another option is tempnam It will create a temp file with a unique name.
Note: If PHP cannot create a file in the specified dir parameter, it falls back on the system default.
Basic example:
$filename = tempnam($dir, $prefix);
unlink($filename)//we don't need the tempfile just the name
Also note: If you change the filename it might not be unique.