{"id":26377,"date":"2016-05-22T03:08:56","date_gmt":"2016-05-21T21:08:56","guid":{"rendered":"https:\/\/www.usefulblogging.com\/?p=26377"},"modified":"2026-01-28T21:59:28","modified_gmt":"2026-01-28T15:59:28","slug":"create-folder-doesnt-already-exist","status":"publish","type":"post","link":"https:\/\/www.usefulblogging.com\/create-folder-doesnt-already-exist\/","title":{"rendered":"How to Create a Folder If It Doesn&#8217;t Already Exist"},"content":{"rendered":"\n<p>Have issue with creating a folder if it doesn&#8217;t already exist? If you&#8217;ve run into a few cases with WordPress installs with Bluehost where you&#8217;ve encountered errors with your&nbsp; WordPress theme because the uploads folder wp-content\/uploads was not present. Apparently the Bluehost cPanel WP installer does not create this folder, though HostGator does.<\/p>\n\n\n\n<p>So you need to add code to my theme that checks for the folder and creates it otherwise. This article will show you how to create a folder if it doesn&#8217;t already exist.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-create-a-folder-if-it-doesn-t-already-exist\">Create a Folder If It Doesn&#8217;t Already Exist<\/h3>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><code>if (!file_exists('path\/to\/directory')) {<br>\nmkdir('path\/to\/directory', 0777, true);<br>\n}<\/code><\/p>\n\n\n\n<p><strong>Note<\/strong>: 0777 is already the default mode for directories and may still be modified by the current umask.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have issue with creating a folder if it doesn&#8217;t already exist? If you&#8217;ve run into a few cases with WordPress &#8230; <a title=\"How to Create a Folder If It Doesn&#8217;t Already Exist\" class=\"read-more\" href=\"https:\/\/www.usefulblogging.com\/create-folder-doesnt-already-exist\/\" aria-label=\"Read more about How to Create a Folder If It Doesn&#8217;t Already Exist\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":25828,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[127],"tags":[10],"class_list":["post-26377","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-wordpress","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33","no-featured-image-padding"],"_links":{"self":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts\/26377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/comments?post=26377"}],"version-history":[{"count":1,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts\/26377\/revisions"}],"predecessor-version":[{"id":86307,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts\/26377\/revisions\/86307"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/media\/25828"}],"wp:attachment":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/media?parent=26377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/categories?post=26377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/tags?post=26377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}