admin管理员组文章数量:1122846
I have various media file uploads that I need to section off into different subdirectories, for example:
example/assets/Uploads
example/assets/team
They all go under "/assets" but if I try to change my directory afterward, the media library also switches the location of where it looks for the images.
I have:
define('UPLOADS', '');
Then in my plugin file, the following works, but I can't change it if I want the media library to see my previous uploads:
add_filter('upload_dir', 'set_upload_folder', 999);
function set_upload_folder($uploadData) {
$myDir = '/assets/uploads';
$mainSiteURL = get_site_url();
$uploadData['basedir'] = trailingslashit(ABSPATH) . $myDir;
$uploadData['baseurl'] = $mainSitURL . $myDir;
$subdir = $uploadData['subdir'];
$uploadData['path'] = $uploadData['basedir'] . $subdir;
$uploadData['url'] = $uploadData['baseurl'] . $subdir;
return wp_parse_args($uploadData, $uploadData);
}
本文标签: phpChanging upload directory temporarily
版权声明:本文标题:php - Changing upload directory temporarily 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301784a1931297.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论