how to save massive files on your server

Hello everyone,

i have a question about saving files to the webser, what is the best way to save your media files without duplicate names?

because if you have allot of file uploads, how can you ensure there is not a file with the same filename?

i was thinking about this, but i dont know if the is the right option,

the php uniq_id function and place the filename after it, and a

table called Files, with a field called url witch will save the url to the file.

will this be a good idea?