Posted By

luman on 10/19/09


Tagged

file random name


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrianCoyDesign


Randomize File Name


 / Published in: PHP
 

URL: http://css-tricks.com/snippets/php/randomize-file-name/

  1. function randomizeFileName( $real_file_name ) {
  2. $name_parts = @explode( ".", $real_file_name );
  3. $ext = "";
  4. if ( count( $name_parts ) > 0 ) {
  5. $ext = $name_parts[count( $name_parts ) - 1];
  6. }
  7. return substr(md5(uniqid(rand(),1)), -16) . "." . $ext;
  8. }

Report this snippet  

You need to login to post a comment.