Create Random Folders - PHP

前端 未结 3 1648
执笔经年
执笔经年 2021-01-05 13:55

I have developed an API integration, It contains multiple image/file uploads. There are name conflicts if multiple users uploads file with the same name.

I\'ve plan

3条回答
  •  醉酒成梦
    2021-01-05 14:34

    For things like this, I've found the php function uniqid to be useful. Basically, something like this:

    $dirname = uniqid();
    mkdir($dirname);
    

    And then just move the uploaded file to this directory.

    Edit: Forgot to mention, the directory name is not random, but is guaranteed to be unique, which seems to be what you need.

提交回复
热议问题