It would be best if we retooled upload.js into a single ajax/api call.
one that checks for:
-name exists
-name allowed (file extensions checks)
-name normalization (think $wgCapitalizedNamespaces)
Better to do these checks serverside, then to reproduce them (often incompletely) in Javascript on the clientside.
Version: unspecified
Severity: enhancement