Ultimately, the temporary file names generated by PHP use the mkstemp / mktemp function, which ensures that the file name is unique. If the file name that it generates already exists, it will try to generate a non-existent file name several times.
On Windows, PHP uses GetTempFileName , which gives the same guarantee of uniqueness.
In any case, if functions cannot return a unique file name, they return an error value, and PHP will not return the file name to you.
source share