treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Randomize File Name

Last updated on:

function randomizeFileName( $real_file_name ) {
               $name_parts = @explode( ".", $real_file_name );
               $ext = "";
               if ( count( $name_parts ) > 0 ) {
                       $ext = $name_parts[count( $name_parts ) - 1];
               }
               return substr(md5(uniqid(rand(),1)), -16) . "." . $ext;
}
View Comments

Comments

  1. Osirix

    Hi Thanks for the snippet much needed

Leave a Comment

Use markdown or basic HTML and be nice.