What I'd like to do is instead of reporting an error saying the file name already exists, choose a different name for the file that's available. How do I assign a unique name to the file (for example, filename2.jpg, filename3.jpg)? I can do it using what I know about do while loops, but I'm not sure if there's a particularly simple or built-in way.
I believe that the $_FILES['field_name']['tmp_name'] value is similarly constructed via a uniqid-like method, so you could probably just use that (filtered through basename() to strip off the directory portion of the path).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation