PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
There are many ways of generating a good filename. uniqid() can be combined with the username, microtime(), user-agent string... all sorts of data... then hashed. The variety is endless. It may also be said to use a longer hash such as sha1() or sha256; even different encoding schemes can be useful (different from simple hex.) In the end, it's always possible to have a collision, so make sure your code can handle such an event and all will be happy.
feyd wrote:There are many ways of generating a good filename. In the end, it's always possible to have a collision, so make sure your code can handle such an event and all will be happy.
Even with tempnam?
The temporary file is also created to avoid a race condition where the file might appear in the filesystem between the time the string was generated and before the script gets around to creating the file.
There are 10 types of people in this world, those who understand binary and those who don't