{"id":2095,"date":"2024-08-10T13:59:45","date_gmt":"2024-08-10T03:59:45","guid":{"rendered":"https:\/\/ntsblog.homedev.com.au\/?p=2095"},"modified":"2024-08-10T18:41:18","modified_gmt":"2024-08-10T08:41:18","slug":"wordpress-on-plesk-missing-a-temporary-folder","status":"publish","type":"post","link":"https:\/\/ntsblog.homedev.com.au\/index.php\/2024\/08\/10\/wordpress-on-plesk-missing-a-temporary-folder\/","title":{"rendered":"WordPress on Plesk Missing a temporary folder"},"content":{"rendered":"<div id=\"ntsbl-575937298\" class=\"ntsbl-before-content ntsbl-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-6288941070289539\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:inline-block;width:728px;height:90px;\" \ndata-ad-client=\"ca-pub-6288941070289539\" \ndata-ad-slot=\"9356781486\"><\/ins> \n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n<h2 class=\"wp-block-heading\">The Issue<\/h2>\n\n\n\n<p>My hosting provider recently moved my WordPress environment between Servers and since then when attempting to upload images to my blog posts I got the dreaded, &#8220;Missing a temporary folder&#8221; message.<\/p>\n\n\n\n<p>This is a windows host, shared hosting on plesk.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What the internet says<\/h2>\n\n\n\n<p>The internet says its an easy fix. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Find your wp-config.php file<\/li>\n\n\n\n<li>Add the following line above \/* That&#8217;s all, stop editing! Happy publishing. *\/<\/li>\n\n\n\n<li>Everything should work<\/li>\n<\/ol>\n\n\n\n<pre title=\"Suggested Fix\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php line-numbers\">define('WP_TEMP_DIR', dirname(__FILE__) . '\/wp-content\/temp\/');<\/code><\/pre>\n\n\n\n<p>For me this did not work!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Trouble shooting<\/h2>\n\n\n\n<p>So, to see what was actually going on I wanted to see the PHP logs.<\/p>\n\n\n\n<p>To do this I have the following section in my wp-config.php<\/p>\n\n\n\n<pre title=\"Enable Debugging\" class=\"wp-block-code\"><code lang=\"php\" class=\"language-php line-numbers\">\/\/Enable debug lines when having issues\ndefine('WP_DEBUG', true);\ndefine('WP_DEBUG_LOG', true);\ndefine('WP_DEBUG_DISPLAY', true);\ndefine( 'SCRIPT_DEBUG', true );<\/code><\/pre>\n\n\n\n<p>With this on, I attempted my file upload and again got the &#8220;Missing a temporary folder&#8221; error.<\/p>\n\n\n\n<p>On my plesk server the log location for my php errors was <code>.\\logs\\php_errors\\ntsblog.homedev.com.au\\php_error.log<\/code><\/p>\n\n\n\n<p>Looking in the log I found the following message..<br><code>PHP Warning: PHP Request Startup: open_basedir restriction in effect. File(C:\\Users\\IWAM_P~1\\AppData\\Local\\Temp) is not within the allowed path(s): (C:\\inetpub\\vhosts\\homedev.com.au\\;C:\\Windows\\Temp) in Unknown on line 0<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The fix<\/h2>\n\n\n\n<p>So it appears that WordPress is trying to open the %LOCALAPPDATA% path, which is for the Plesk User that is running the wordpress website that it does not have as a valid path.<\/p>\n\n\n\n<p>On searching this <code>open_basedir<\/code> issue, it said you could set this in the php.ini file.<\/p>\n\n\n\n<p>Hmm, on shared hosting I don&#8217;t have access to the php.ini file. A quick search on how to override the php.ini file suggests that from PHO &gt;= 5.3 you can override in a sub-directory with a <code>user.ini<\/code> file.<\/p>\n\n\n\n<p>So in the root of the WordPress site create a new file called user.ini and add I added this content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[PHP]\nopen_basedir=\"C:\/Inetpub\/vhosts\/homedev.com.au\\;C:\\Windows\\Temp\\;C:\\Users\\IWAM_P~1\\AppData\\Local\\Temp\"<\/code><\/pre>\n\n\n\n<p>Save this file.<\/p>\n\n\n\n<p>Refresh your page and try again, and it is fixed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Final Notes<\/h3>\n\n\n\n<p>It would appear that I had hit similar issues in the past as the user.ini file actually already existed. I think the <code>c:\\Windows\\Temp<\/code> was probably what was happing on the previous host, hence why the <code>open_basedir<\/code> line was already there as you could see from the original logged error message.<\/p>\n\n\n\n<p>My full file looked like this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[PHP]\nopen_basedir=\"C:\/Inetpub\/vhosts\/homedev.com.au\\;C:\\Windows\\Temp\\;C:\\Users\\IWAM_P~1\\AppData\\Local\\Temp\"\nerror_reporting=22519\nerror_log=\"C:\\Inetpub\\vhosts\\homedev.com.au\\logs\\php_errors\\ntsblog.homedev.com.au\\php_error.log\"<\/code><\/pre>\n\n\n\n<p>The error_log entry is why my logfile sits where it does. The hard coded <code>error_reporting<\/code> code is related to PHP error logging, I don&#8217;t remember \ud83d\ude42<br>Cheers <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fix Missing a temporary folder error when hosted on windows shared hosting with plesk<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[22],"tags":[56],"class_list":["post-2095","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-wordpress"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts\/2095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=2095"}],"version-history":[{"count":0,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts\/2095\/revisions"}],"wp:attachment":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=2095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/categories?post=2095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/tags?post=2095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}