How are tmp file names in php generated?

How are tmp (downloaded) file names written in php? What is the mechanism of this? Can I rely on them to always be unique?

The problem is that I want to copy all the downloaded files into one const directory, and I'm not sure if the tmp names will be repeated in the history of my server.

+4
source share
1 answer

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.

+1
source

Source: https://habr.com/ru/post/1441637/


All Articles