How are tmp file names (uploaded) in php generated? What is the mechanism of it? Can I rely that they are always unique?
如何生成php中的tmp文件名(上传)?它的机制是什么?我能相信它们总是独一无二的吗?
The problem is that I want to copy all uploaded files into one const directory and I'm not sure if tmp names will reoccur in the history of my server running.
问题是我想将所有上传的文件复制到一个const目录中,我不确定tmp名称是否会在我运行的服务器的历史记录中重新出现。
1 个解决方案
#1
1
Ultimately the temporary filenames generated by PHP use the function mkstemp
/ mktemp
which guarantees the filename will be unique. If a filename that it generates already exists, it will try a number of times to generate a non-existent filename.
最终,PHP生成的临时文件名使用函数mkstemp / mktemp,它保证文件名是唯一的。如果它生成的文件名已经存在,它将尝试多次生成不存在的文件名。
On Windows, PHP uses GetTempFileName
which makes the same guarantee about uniqueness.
在Windows上,PHP使用GetTempFileName,它对唯一性提供相同的保证。
In either case, if the functions can't return a unique filename, they return an error value and PHP would not return a filename to you at all.
在任何一种情况下,如果函数不能返回唯一的文件名,它们将返回错误值,PHP根本不会返回文件名。
#1
1
Ultimately the temporary filenames generated by PHP use the function mkstemp
/ mktemp
which guarantees the filename will be unique. If a filename that it generates already exists, it will try a number of times to generate a non-existent filename.
最终,PHP生成的临时文件名使用函数mkstemp / mktemp,它保证文件名是唯一的。如果它生成的文件名已经存在,它将尝试多次生成不存在的文件名。
On Windows, PHP uses GetTempFileName
which makes the same guarantee about uniqueness.
在Windows上,PHP使用GetTempFileName,它对唯一性提供相同的保证。
In either case, if the functions can't return a unique filename, they return an error value and PHP would not return a filename to you at all.
在任何一种情况下,如果函数不能返回唯一的文件名,它们将返回错误值,PHP根本不会返回文件名。