WordPress常用函数wp upload dir

来自站长百科
跳转至: 导航、​ 搜索

导航: 上一页 | 首页 | WordPress中文论坛 | WordPress主机 | CMS程序 | 论坛程序 | ECShop | ShopNC | PowerEasy

用法[ ]

<?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' )."\n";
echo 'upload_path: ' .get_option( 'upload_path' )."\n";
echo 'upload_url_path: ' .get_option( 'upload_url_path' )."\n";
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: 1upload_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] => )

相关条目[ ]