php Unique filename when uploading

后端 未结 5 1583
生来不讨喜
生来不讨喜 2020-12-11 04:14

I\'ve a submit discussion form with image upload in my website. Now, I want to upload a unique file name when the user submits their image so that I can show the result of a

5条回答
  •  無奈伤痛
    2020-12-11 04:37

    If you need a unique name, you can use uniqid.

    $filename = uniqid() . '.jpeg';
    

    Be warned though that it will only be unique across one machine, ie it can generate the same thing if you run it at the very same time on two different machines.

提交回复
热议问题