How to generate random names for images that are going to be uploaded?

0

I'm having trouble creating random names for my images.    I was having the md5 function (mt_rand (1,10000) but I did not succeed using it together with has :: file.

    public function anexar () {
        if(Input::hasFile('file')){
          $file = Input::file('file');
          $file->move('uploads', $file->getClientOriginalName());
          return 'Anexado com sucesso';
          }
        } 
    }
    
asked by anonymous 16.03.2016 / 22:36

1 answer

1

You can use the uniqueid () function of PHP. It generates a unique id taking into account the time, in microseconds. You can pass a prefix to the function that it will concatenate with the generated id.

For more information: link

    
16.03.2016 / 22:41