生成随机值以分配上载的文件

I have to assign random value to uploaded file. here is my component code n the controller code where i call the component but it's creating a bud so need a help

//component
App::uses('Component', 'Controller');
    $components = array('Useful');
    class UsefulComponent extends Component {

        /*generate random numbers*/
        public function random_code() {
             $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
             srand((double)microtime()*1000000);
             $i = 0;
             $pass = '' ;
             while ($i <= 10) {
                $num = rand() % 33;
                $tmp = substr($chars, $num, 1);
                $pass = $pass . $tmp;
                $i++;
             }
            return $pass;
        }
    }

//contrroller
$random_number = $this->Useful->random_code();
            $random_number.$this->request->data['User']['profile_photo']['tmp_name'];

There is ready function for unique file names in php tempnam

$uniqueFilePath = tempnam("/mydir", "file_prefix");

$uploadedFile = $this->request->data['User']['profile_photo']['tmp_name'];
move_uploaded_file($uploadedFile, $uniqueFilePath);

Try uniqid() :

<?php 
    $name = uniqid();
    $tmp_name = $_FILES["pictures"]["tmp_name"];
    move_uploaded_file($tmp_name, $name);
?>