You will have to agree that your file names will probably not be short, but RFC 4122 is the best practice, and one of the fastest PHP implementations is this:
function mimec_uuid()
{
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
mt_rand( 0, 0x0fff ) | 0x4000,
mt_rand( 0, 0x3fff ) | 0x8000,
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) );
}
Personally, however, I used the following (faster and shorter) algorithm for projects that do not need to scale like Flickr:
function xuuid()
{
return md5(microtime() . mt_rand( 0, 0xffff ));
}