gpt4 book ai didi

upload - 如何上传特定页面 “http://domain_name/folder_name”下的一些媒体文件?

转载 作者:行者123 更新时间:2023-12-02 01:25:30 26 4
gpt4 key购买 nike

我想上传特定文件夹中的文件,例如 http://domain_name/folder_name .

请记住,不是在 http://domain_name/wp-content/uploads/folder_name/file 中.

最佳答案

试试这个代码。

add_filter('upload_dir', 'upload_image_specific_calback');
function upload_image_specific_calback( $param ){

//$_GET['post'] which is your target post like 10 is post id.
//After click update button.
if(isset($_GET['post'])){
if($_GET['post'] == 10){
$param = array(
'path' => get_home_path().'logos',
'url' => home_url().'/logos',
'subdir' => '',
'basedir' => get_home_path(),
'baseurl' => home_url(),
'error' => false
);
}
}

//$_POST['post_id'] which is your target post like 10 is post id.
//instant upload time before save
if(isset($_POST['post_id'])){
if($_POST['post_id'] == 10) {
$param = array(
'path' => get_home_path().'logos',
'url' => home_url().'/logos',
'subdir' => '',
'basedir' => get_home_path(),
'baseurl' => home_url(),
'error' => false
);
}
}

error_log("path={$param['path']}");
error_log("url={$param['url']}");
error_log("subdir={$param['subdir']}");
error_log("basedir={$param['basedir']}");
error_log("baseurl={$param['baseurl']}");
error_log("error={$param['error']}");
return $param;
}

关于upload - 如何上传特定页面 “http://domain_name/folder_name”下的一些媒体文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35130833/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com