首页    >    中文手册    >   常用函数-wp_upload_dir()

常用函数-wp_upload_dir()

用法

<?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啦! 转载请注明出处。