操做方法: php
在wordpress程序的wp-admin/includes/目錄中找到file.php文件,並進行編輯,在327行左右找到如下代碼: wordpress
// Move the file to the uploads dir $new_file = $uploads['path'] ."/$filename"; if(false=== @ move_uploaded_file( $file['tmp_name'], $new_file ) ) return$upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.'), $uploads['path'] ) );
將其替換爲: code
// Move the file to the uploads dir $new_file = $uploads['path'] ."/".date("YmdHis").floor(microtime()*1000).".".$ext; if(false=== @ move_uploaded_file( $file['tmp_name'], $new_file ) ) return$upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.'), $uploads['path'] ) );
PS:總體代碼其實就是替換掉了」/$filename」; blog
保存後覆蓋原文件,那麼上傳文件就會以「年月日時分秒+千位毫秒整數」的格式重命名文件了,如「20121023122221765.jpg」 get