{"id":605,"date":"2021-12-28T18:15:01","date_gmt":"2021-12-28T16:15:01","guid":{"rendered":"https:\/\/www.petersplanet.nl\/?p=605"},"modified":"2021-12-29T13:54:11","modified_gmt":"2021-12-29T11:54:11","slug":"wordpress-unable-to-create-directory","status":"publish","type":"post","link":"https:\/\/www.petersplanet.nl\/index.php\/2021\/12\/28\/wordpress-unable-to-create-directory\/","title":{"rendered":"WordPress Unable to create directory"},"content":{"rendered":"\n<p>When you get the error &#8221; Unable to create directory wp-content\/uploads\/2021\/12 &#8221; when you are uploading media in WordPress something is wrong with the folder permissions. Another well known error is &#8220;The uploaded file could not be moved to wp-content\/uploads\/2021\/12.&#8221;<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>In my case both SELinux and permissions on the uploads folder appeared to be the problem.<br>Fix the folder permissions by making user <em>apache <\/em>owner.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd &lt;to the wp-content folder&gt;\nchown -R apache uploads\/<\/code><\/pre>\n\n\n\n<p>In \/var\/log\/audit\/audit.log you can see that SELinux is denying write access.<br>Fix the SELinux folder permissions by giving it write access to the uploads folder.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>semanage fcontext -a -t httpd_sys_rw_content_t \"\/var\/www\/html\/wp-content\/uploads(\/.*)?\"\nrestorecon -Rv \/var\/www\/html\/wp-content\/uploads\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you get the error &#8221; Unable to create directory wp-content\/uploads\/2021\/12 &#8221; when you are uploading media in WordPress something is wrong with the folder permissions. Another well known error is &#8220;The uploaded file could not be moved to wp-content\/uploads\/2021\/12.&#8221;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-605","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/605","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/comments?post=605"}],"version-history":[{"count":8,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/605\/revisions"}],"predecessor-version":[{"id":620,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/605\/revisions\/620"}],"wp:attachment":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/media?parent=605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/categories?post=605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/tags?post=605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}