PHP使用唯一名称从字符串创建文件

I am sending an xhr base64 encoded string from JavaScript to a php file. In php I get the content and put it in a file:

<?php
  $img = trim($_POST["base64"]);

  $img = str_replace('data:image/png;base64,', '', $img);
  $img = str_replace(' ', '+', $img);
  $data = base64_decode($img);
  file_put_contents('image.png', $data);

  echo 'image.png';
?> 

How can I create a unique file name, instead of file_put_contents in image.png, set it into a /tmp folder and return the unique URL?

Thanks you.