What happens when two files with the same name are uploaded?
It will rename the second file for you. If dogs.png exists, Drupal will try dogs_0.png, dogs_1.png and so on, until it finds an unused filename.

The behaviour comes from the $replace parameter to file_save_data(), which can be one of the following:


FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with the destination name exists then its database entry will be updated. If no database entry is found then a new one will be created.
FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
FILE_EXISTS_ERROR - Do nothing and return FALSE.


The default is FILE_EXISTS_RENAME, which is used for managed file form elements like the user profile picture, and file field widgets too.