网上看到的,暂时放在这里。
/**
* @see wp_handle_upload()
*/
function example_wp_handle_upload_prefilter($files){
$files['name'] = md5($files['name']) . $_SERVER['REQUEST_TIME']. mt_rand(0, 10000);
$files['name'] .= '.' . pathinfo($files['name'] , PATHINFO_EXTENSION);
return $files;
}
add_filter('wp_handle_upload_prefilter', 'example_wp_handle_upload_prefilter');
* @see wp_handle_upload()
*/
function example_wp_handle_upload_prefilter($files){
$files['name'] = md5($files['name']) . $_SERVER['REQUEST_TIME']. mt_rand(0, 10000);
$files['name'] .= '.' . pathinfo($files['name'] , PATHINFO_EXTENSION);
return $files;
}
add_filter('wp_handle_upload_prefilter', 'example_wp_handle_upload_prefilter');
通过wp_handle_upload_prefilter这个filter完成重命名的