Wordpress上传文件重命名

Function代码

//wordpress上传文件重命名,by minirizhi.com
function minirizhi_upload_filter($file) {
$time = date("YmdHis");
$file['name'] = $time . "" . mt_rand(1, 100) . "." . pathinfo($file['name'], PATHINFO_EXTENSION);
return $file;
}
add_filter('wp_handle_upload_prefilter', 'minirizhi_upload_filter');
文章目录