{"id":2209,"date":"2024-07-04T19:25:11","date_gmt":"2024-07-04T11:25:11","guid":{"rendered":"https:\/\/qishiya.com\/?p=2209"},"modified":"2024-07-04T19:25:12","modified_gmt":"2024-07-04T11:25:12","slug":"wordpress-%e4%b8%ad%e7%9a%84-wp_upload_dir-%e8%bf%94%e5%9b%9e%e5%80%bc","status":"publish","type":"post","link":"https:\/\/qishiya.com\/?p=2209","title":{"rendered":"wordpress \u4e2d\u7684 wp_upload_dir \u8fd4\u56de\u503c"},"content":{"rendered":"\n<p>\u5728 wordpress \u4e2d\uff0c\u5982\u679c\u8981\u81ea\u5df1\u5199\u63d2\u4ef6\uff0c\u7ecf\u5e38\u4f1a\u7528\u5230 wp_upload_dir \u8fd9\u4e2a\u51fd\u6570\uff0c\u91cc\u9762\u6709\u54ea\u4e9b\u503c\uff0c\u6211\u4eca\u5929\u5728\u547d\u4ee4\u884c\u4e2d\u8dd1\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u5404\u79cd\u503c\u8fd8\u771f\u4e0d\u5c11\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\ninclude( '\/usr\/share\/nginx\/html\/qishiya.com\/wp-load.php' );\n\n\n\necho \"Upload dir: \".PHP_EOL;\necho \"Path: \" . $upload_dir&#91;'path'] . PHP_EOL;\necho \"URL: \" . $upload_dir&#91;'url'] . PHP_EOL;\necho \"Subdir: \" . $upload_dir&#91;'subdir'] . PHP_EOL;\necho \"Basedir: \" .$upload_dir&#91;'basedir'] . PHP_EOL;\necho \"Baseurl: \" . $upload_dir&#91;'baseurl'] . PHP_EOL;\necho $upload_dir&#91;'error'] . PHP_EOL;\n\n$upload_url = ( $upload_dir&#91;'url'] );\n$upload_url_alt = ( $upload_dir&#91;'baseurl'] . $upload_dir&#91;'subdir'] );\n\n\/\/ Now echo the final result\necho \"Upload URL: \" . $upload_url . PHP_EOL; \/\/ Output - http:\/\/example.com\/wp-content\/uploads\/2010\/05\n\n\/\/ Using year and month based folders, the below will be the same as the line above.\necho \"Upload URL alt: \" . $upload_url_alt . PHP_EOL; \/\/ Output - http:\/\/example.com\/wp-content\/uploads\/2010\/05<\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u662f\u5177\u4f53\u7684\u8f93\u51fa\u503c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Upload dir:\nPath: \/usr\/share\/nginx\/html\/qishiya.com\/wp-content\/uploads\/2024\/07\nURL: https:\/\/media.qishiya.com\/2024\/07\nSubdir: \/2024\/07\nBasedir: \/usr\/share\/nginx\/html\/qishiya.com\/wp-content\/uploads\nBaseurl: https:\/\/media.qishiya.com\n\nUpload URL: https:\/\/media.qishiya.com\/2024\/07\nUpload URL alt: https:\/\/media.qishiya.com\/2024\/07\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 wordpress \u4e2d\uff0c\u5982\u679c\u8981\u81ea\u5df1\u5199\u63d2\u4ef6\uff0c\u7ecf\u5e38\u4f1a\u7528\u5230 wp_upload_dir \u8fd9\u4e2a\u51fd\u6570\uff0c\u91cc\u9762\u6709\u54ea\u4e9b\u503c\uff0c\u6211\u4eca\u5929\u5728\u547d\u4ee4\u884c\u4e2d\u8dd1\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u5404\u79cd\u503c\u8fd8\u771f\u4e0d\u5c11\u3002 \u4e0b\u9762\u662f\u5177\u4f53\u7684\u8f93\u51fa\u503c<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[639,597],"tags":[691],"class_list":["post-2209","post","type-post","status-publish","format-standard","hentry","category-woocommerece","category-wordpress","tag-wp_upload_dir"],"_links":{"self":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/2209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2209"}],"version-history":[{"count":1,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/2209\/revisions"}],"predecessor-version":[{"id":2210,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/2209\/revisions\/2210"}],"wp:attachment":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}