gpt4 book ai didi

php 上传时的唯一文件名

转载 作者:可可西里 更新时间:2023-11-01 12:42:57 30 4
gpt4 key购买 nike

我的网站上有一个上传图片的提交讨论表。现在,我想在用户提交图片时上传一个唯一的文件名,这样我就可以显示所有图片的结果并避免重复的文件名。

我如何用 php 做到这一点?如果您需要我的表单处理代码,我会上传它。

最佳答案

可以使用uniqid()函数生成唯一ID

/**
* Generate a unique ID
* @link http://www.php.net/manual/en/function.uniqid.php
* @param prefix string[optional] <p>
* Can be useful, for instance, if you generate identifiers
* simultaneously on several hosts that might happen to generate the
* identifier at the same microsecond.
* </p>
* <p>
* With an empty prefix, the returned string will
* be 13 characters long. If more_entropy is
* true, it will be 23 characters.
* </p>
* @param more_entropy bool[optional] <p>
* If set to true, uniqid will add additional
* entropy (using the combined linear congruential generator) at the end
* of the return value, which should make the results more unique.
* </p>
* @return string the unique identifier, as a string.
*/
function uniqid ($prefix = null, $more_entropy = null) {}

关于php 上传时的唯一文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8563958/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com