常用函数-wp_upload_dir()

用法 <?php $wud = wp_upload_dir(); $old = wp_upload_di…

用法

<?php
$wud = wp_upload_dir();
$old = wp_upload_dir( '2007-11-26 04:26:39' );

echo 'uploads_use_yearmonth_folders: '.get_option( 'uploads_use_yearmonth_folders' )."
";
echo 'upload_path: ' .get_option( 'upload_path' )."
";
echo 'upload_url_path: ' .get_option( 'upload_url_path' )."
";
print_r($old);
print_r($wud);

?>

返回的值

返回的字段包括: [path], [url], [subdir], [basedir], [baseurl], [error]

若成功,返回的数组会有多个索引:’path’ —— 基文件夹与子文件夹,或上传文件夹的完全路径。’url’ —— 基ur与子文件夹,或上传文件夹的绝对路径。’subdir’ —— 子文件夹。’basedir’ —— 没有子文件夹的路径。’baseurl’ ——没有子文件夹的URL路径。’error’ —— 设为false。

WordPress2.6后可返回[basedir] 与[baseurl]字段。

示例

uploads_use_yearmonth_folders: 1
upload_path: /home/example.com/wordpress/wp-content/uploads
upload_url_path: http://www.example.com/wordpress/wp-content/uploads

Array
(
    [path] => /home/example.com/wordpress/wp-content/uploads/2007/11
    [url] => http://www.example.com/wordpress/wp-content/uploads/2007/11
    [subdir] => /2007/11
    [basedir] => /home/example.com/wordpress/wp-content/uploads
    [baseurl] => http://www.example.com/wordpress/wp-content/uploads
    [error] => 
)

Array
(
    [path] => /home/example.com/wordpress/wp-content/uploads/2008/11
    [url] => http://www.example.com/wordpress/wp-content/uploads/2008/11
    [subdir] => /2008/11
    [basedir] => /home/example.com/wordpress/wp-content/uploads
    [baseurl] => http://www.example.com/wordpress/wp-content/uploads
    [error] => 
)

 

 

分类:中文手册

类别:WordPress教程

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT

登录 账号发表你的看法,还没有账号?立即免费 注册