为 Wordpress 编写插件,无法设置上传文件夹。当我用谷歌搜索时发现了这个:
$upload_dir = "images/objects" . (isset($_REQUEST['ObjectNo']) ? "/{$_REQUEST['ObjectNo']}" : "");
$plugin_dir = WP_PLUGIN_DIR . '/' . BGREAL_PLUGIN_NAME;
$plugin_url = WP_PLUGIN_URL . '/' . BGREAL_PLUGIN_NAME;
function sss_configure_upload_dir($path_data)
{
global $upload_dir;
global $plugin_dir;
global $plugin_url;
$path_data['path'] = $plugin_dir . "/" . $upload_dir;
$path_data['url'] = $plugin_url . "/" . $upload_dir;
$path_data['subdir'] = "/" . $upload_dir;
$path_data['basedir'] = $plugin_dir;
$path_data['baseurl'] = $plugin_url;
return $path_data;
}
add_filter('upload_dir', 'sss_configure_upload_dir');
在上传框架打开的页面上,我得到以下信息:
$upl = wp_upload_dir();
echo $upl['path'];`
呼应C:\PATH\TO\HTDOCS\public_html/wp-content/plugins/bg_real/images/objects/11212
问题是,当我打开媒体上传框架并上传图像时,它会保存到,/wp-content/plugins/bg_real/images/objects
因为函数$_REQUEST['ObjectNo']
中缺少async-upload
。
我需要在 querystring 之后组织在文件夹中的图像ObjectNo
。
有任何想法吗?在 Google 等上花费了数小时并尝试了不同的方法,但似乎都没有奏效。
谢谢,