I was wondering, without using any kind of user info (id, nickname, age, etc), what would be the best way to assure filename uniqueness using php in a large database with high traffic and most probably simultaneously between many users? I am using $file = time() for example but I would like to know if this should suffice whenever two users might go over this code at the same time (at a large large large scale, 10000 users at the same time and the same function ran 200 at the same time).
Best way to assure uniqueness in filename with php
php
If you don't want to hash the entire file to generate a unique id, a couple of other ways come to mind:You can use an 'auto increment' column in a database.  Each insert gives you a unique id, managed by the database.  Then base your file name off of that.You can create a unique identifier from the existing session id or remote ip address and the time.  You might even use the file size as well.  Concatinating them together should prevent file name collisions at a much better reliability than just using the time.  You can implement some other single process service that distributes unique id's upon request.  The requesting PHP script would request an id and wait until one was returned before proceeding.  Its unlikely simply distributing id's would be a bottleneck even at very high levels of traffic.