In a website how can the server make sure uploaded files wont have the same name.

In a website how can the server make sure uploaded files wont have the same name.

This is a discussion on In a website how can the server make sure uploaded files wont have the same name. within the Tech Board forums, part of the Community Boards category; I was reading this question on stackoverflow and wonder, what does the server do when a user uploads a file ...

In a website how can the server make sure uploaded files wont have the same name.

I was reading this question on stackoverflow and wonder, what does the server do when a user uploads a file that's name is already used? For example in Facebook I'm sure 1000s of people uploaded a profile picture named profilepic.jpg

Of course those files are renamed on the server.
In the simplest case, each file just gets a unique ID which is an increasing number: 1.jpg, 2.jpg, 3.jpg, ...
But probably they use some kind of hashing to generate the filename.