简体   繁体   English

PHP:$ _FILES ['tmp_name']是唯一的吗?

[英]PHP: Is the $_FILES ['tmp_name'] unique?

I've created my first site with an image uploading feature and this just crossed my mind. 我已经创建了第一个具有图像上传功能的网站,这让我无所适从。 Is ['tmp_name'] in $_FILES a unique value like in uniqid() ? $_FILES['tmp_name']是否像uniqid()一样是唯一值?

It's unique for the time being. 暂时是唯一的。 As soon as you delete it (it should be deleted automatically when the script finishes) some file may and eventually will get the same name. 删除它(脚本完成后应自动将其删除)后,某些文件可能会最终获得相同的名称。 PHP manual doesn't say that tmp_name is unique, so simplified answer is no , it isn't. PHP手册没有说tmp_name是唯一的,因此简化的答案是no ,不是。

Yes, PHP generates this to uniquely name an uploaded file. 是的,PHP生成此文件以唯一命名一个上传的文件。 You can't guarantee the file will stay around forever depending on where it's stored to. 您不能保证文件会永久保存,具体取决于文件的存储位置。 Often it's /var/tmp 通常是/ var / tmp

It's unique in that you can never have two files with the same name at any given time. 它的独特之处在于,在任何给定时间都不能拥有两个具有相同名称的文件。 However since the files are temporary they will most likely be deleted shortly after their creation, so the filenames free up again. 但是,由于文件是临时文件,因此很可能在创建后不久将其删除,因此文件名会再次释放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM