I made an upload script in PHP. How do I avoid overwriting files?
<p>I've made an image upload script using the <code>move_uploaded_file</code> function. This function seems to overwrite any preexisting file with the new one. So, I need to check if the target location already has a file. If it does then I need to append something to the filename(before the extension so that the file name is still valid) so the filename is unique. I'd like to have the change be minimal instead of something like appending the datetime, if possible. </p>

<p>How can I do this with PHP?</p>
