我用一些代码
将此添加到函数。php更改上载的文件目录
// change dir for anomaly images
function example_Dir( $param ){
$param[\'path\'] = \'/home/yoursite/domains/yoursite.com/public_html/wp-content/uploads/example\';
$param[\'url\'] = \' https://yoursite.com/wp-content/uploads/example\';
return $param;
}
以下是表格:
<form action="" enctype="multipart/form-data" method="post" >
<input type="file" name="file">
<input type="submit">
</form>
那么您需要的PHP代码是
if(isset($_FILES[\'file\'])){
$file = $_FILES[\'file\'];
add_filter(\'upload_dir\', \'example_Dir\');
$Result = wp_handle_upload($file , $upload_overrides);
remove_filter(\'upload_dir\' , \'example_Dir\');
}
完成!