---
title: "How to fix \"Missing a temporary folder\" in WordPress"
url: https://wpministry.co/errors/missing-a-temporary-folder/
description: "PHP could not create the temporary file every upload begins as. The folder is a PHP setting on the server, and defining WP_TEMP_DIR does not clear this message."
lang: en-US
---

Skip to content

# How to fix "Missing a temporary folder" in WordPress

PHP could not create the temporary file that every upload begins as, so WordPress was handed an error instead of a file. The folder is a PHP setting on the server. Defining WP_TEMP_DIR in wp-config.php does not clear the message, because that sets a different folder.

By

WP Ministry

Published

October 7, 2026

Tested on

WordPress 7.1.4, PHP 8.3.36

## In short

- Nothing is lost. The upload did not arrive, and everything already on the site is as it was.
- The folder is PHP's and is set on the server. WordPress has no setting for it.
- Defining WP_TEMP_DIR does not clear this message. It moves a different folder.
- A short PHP file shows which folder PHP uses and what is wrong with it.
- Where you cannot change PHP's settings, the repair is the host's to make. Send them what the check shows.

"Missing a temporary folder." means PHP could not create the temporary file that every upload begins as. PHP receives an uploaded file itself and stores it in a folder set on the server. When it cannot create a file there, WordPress is handed an error in place of the file and shows this message.

Nothing has been lost. The file you sent did not arrive, and everything already on the site is as it was. Installing from the plugin directory and running updates send no file from your computer, so they do not show this message.

## Two temporary folders, and which one this is

You may have been told to add a `WP_TEMP_DIR` line to `wp-config.php`. That line sets a different folder.

- **PHP's folder** is where an upload lands. It is the one named by PHP's `upload_tmp_dir` setting or, when that is empty, the system's temporary folder, such as `/tmp`. PHP's manual lists `upload_tmp_dir` among the settings that can be made only in `php.ini` or the web server's configuration. A `php_value` line in `.htaccess`, a `.user.ini` file and `ini_set()` in `wp-config.php` do not change it.
- **WordPress's folder** is where WordPress puts temporary files it makes itself, such as the download of an update. It uses `WP_TEMP_DIR` if that is defined. Otherwise it takes the first of these it can write to: the system's temporary folder, `upload_tmp_dir`, then `wp-content`.

This message comes only from the first. In WordPress's code it is the text for one PHP upload error, number 6, and nothing else. Defining `WP_TEMP_DIR` moves WordPress's folder and leaves uploads failing with the same message. When WordPress's own folder fails, the message is a different one, such as "Could not create temporary file."

## Where it goes wrong

A page request passes through each of these in turn. This one comes from **PHP, the language WordPress runs on**.

1. Browser
2. DNS
3. HTTPS
4. CDN or firewall
5. Web server
6. PHP (this error comes from here)
7. WordPress
8. Database and files

## What causes it

- ### PHP's temporary folder is missing, or PHP may not write to it
  Common
  PHP's upload_tmp_dir setting, or the system's own temporary folder, points at a folder that is not there or that the user PHP runs as cannot write to. Nothing in WordPress sets this folder, so look for a change on the server, such as a move, a different PHP version or an edited PHP setting.
  Fix: Find out which folder PHP uses and what is wrong with it, or Ask the host to repair PHP's temporary folder, or Set upload_tmp_dir where you control PHP's settings
- ### open_basedir does not include the temporary folder
  Sometimes
  open_basedir limits PHP to a list of folders. PHP's manual says the system's temporary folder has to be in that list for an upload to succeed.
  Fix: Find out which folder PHP uses and what is wrong with it, or Ask the host to repair PHP's temporary folder, or Add the temporary folder to open_basedir
- ### The disk or the account's quota has no room for a new file
  Sometimes
  PHP cannot create the temporary file when the disk is full, or when the account has used up its allowance of space or of files.
  Fix: Find out which folder PHP uses and what is wrong with it, or Ask the host to repair PHP's temporary folder, or Free space on the disk

## How to fix it

### Find out which folder PHP uses and what is wrong with it

- Easy
- Low risk
- About 10 minutes
- Steps tested on WordPress 7.1.4
1. #### Step 1: Create a file named temp-check.php
   Put it in the site's main folder, beside `wp-config.php`, with this content.
   temp-check.php Copy

   ```
   <?php
   header( 'Content-Type: text/plain' );
   function report( $label, $folder ) {
   	echo $label, ': ', $folder, "\n";
   	error_clear_last();
   	$exists = @is_dir( $folder );
   	$error  = error_get_last();
   	if ( $error && false !== strpos( $error['message'], 'open_basedir' ) ) {
   		echo "  Inside open_basedir: no\n";
   		return;
   	}
   	echo '  Exists: ', $exists ? 'yes' : 'no', "\n";
   	echo '  PHP can write to it: ', $exists && is_writable( $folder ) ? 'yes' : 'no', "\n";
   	$free = $exists ? @disk_free_space( $folder ) : false;
   	echo '  Free space: ', false === $free ? 'unknown' : round( $free / 1048576 ) . ' MB', "\n";
   }
   $set   = ini_get( 'upload_tmp_dir' );
   $limit = ini_get( 'open_basedir' );
   $user  = function_exists( 'posix_getpwuid' ) ? posix_getpwuid( posix_geteuid() )['name'] : 'unknown';
   echo 'PHP runs as: ', $user, "\n";
   echo 'open_basedir: ', $limit ? $limit : 'not set', "\n";
   echo 'upload_tmp_dir: ', $set ? $set : 'not set', "\n";
   if ( $set ) {
   	report( 'Folder named by upload_tmp_dir', $set );
   }
   report( 'System temporary folder', sys_get_temp_dir() );
   ```

2. #### Step 2: Open it in your browser
   Go to `https://example.com/temp-check.php`, with your own domain. Run it this way and not from a command line, where PHP can have other settings.
3. #### Step 3: Read the answers
   When `upload_tmp_dir` names a folder, PHP tries it first and falls back to the system's folder if it cannot write there. The message appears when neither can be used.
   - **"Inside open_basedir: no"**: PHP is not allowed to use that folder. Go to the fix for `open_basedir`.
   - **"Exists: no" or "PHP can write to it: no"**: the folder is missing, or closed to the user on the first line. Ask the host, or set `upload_tmp_dir` yourself.
   - **"Free space" at or near 0 MB**: free some space.
   - **Every answer is good**: the cause is one PHP's code cannot see, such as a quota on the number of files. Take it to the host.
4. #### Step 4: Delete the file
   It tells anyone who opens it how your server is laid out.

**To undo it:** Delete temp-check.php.

### Ask the host to repair PHP's temporary folder

- Easy
- No risk
- About 15 minutes

On hosting where you cannot edit `php.ini`, this is the fix. The folder and the setting belong to the server.

1. #### Step 1: Send the host the facts
   text Copy

   ```
   Uploads to my site fail with "Missing a temporary folder."
   (PHP upload error 6, UPLOAD_ERR_NO_TMP_DIR).
   PHP runs as: (from the check)
   open_basedir: (from the check)
   upload_tmp_dir: (from the check)
   System temporary folder: (from the check, with the lines under it)
   Please make sure the folder PHP stores uploads in exists, can be
   written to by that user, is inside open_basedir, and has free space
   and free inodes. Or set upload_tmp_dir to a folder in my account.
   ```

2. #### Step 2: Say what changed
   If the message began after a move to another server, a change of PHP version or a change of plan, say so. It tells them where to look.
3. #### Step 3: Upload again when they reply
   Run the check once more too. Its answers should all be good.

How to tell whether a fault is the host's or the site's (https://wpministry.co/blog/fix-wordpress-hosting-problems/) covers what else to send a host and what to expect back.

### Set upload_tmp_dir where you control PHP's settings

- Advanced
- Low risk
- About 15 minutes

Use this on a server you run yourself, or where your hosting panel lets you edit `php.ini`.

1. #### Step 1: Make a folder for uploads to land in
   Put it inside your account and outside the folder the site is served from, for example `/home/example/tmp`. The user on the first line of the check has to be able to write to it. The guide to file permissions (https://wpministry.co/blog/wordpress-file-permissions-guide/) explains which user that is, and why 755 is enough when that user owns the folder. If `open_basedir` is set, choose a folder inside its list, so that WordPress can read the file once PHP has stored it.
2. #### Step 2: Name the folder in php.ini
   In an Apache virtual host the same setting is `php_admin_value upload_tmp_dir /home/example/tmp`. In a PHP-FPM pool it is `php_admin_value[upload_tmp_dir] = /home/example/tmp`.
   php.ini Copy

   ```
   upload_tmp_dir = /home/example/tmp
   ```

3. #### Step 3: Restart PHP
   PHP reads `php.ini` when it starts. Where PHP runs as part of the web server, restart the web server. Where it runs as PHP-FPM, restart PHP-FPM.
4. #### Step 4: Run the check again
   The `upload_tmp_dir:` line should name your folder, with "PHP can write to it: yes" under it. Then upload the file.

**To undo it:** Remove the line and restart PHP.

### Add the temporary folder to open_basedir

- Takes care
- Back up first
- About 10 minutes
- Steps tested on WordPress 7.1.4

`open_basedir` lists the folders PHP may use. Who can change the list depends on where it was set.

- **In your hosting panel's PHP settings:** add the temporary folder to the list there.
- **By the host, in the server's configuration:** only the host can change it. PHP lets a site narrow a list the server set, never widen it. Send the host what the check shows, as in the second fix.
- **In your site's own `.htaccess` file:** follow these steps. They are for Apache with PHP running as part of the web server.
1. #### Step 1: Find the line
   Open `.htaccess` in the site's main folder and search for `open_basedir`. If it is not there, the list is set in one of the other two places.
2. #### Step 2: Add the folder to the end of the list
   Use the folder the check calls "System temporary folder", after a colon. For a site in `/home/example/public_html` and a temporary folder of `/tmp`, the line becomes:
   .htaccess Copy

   ```
   php_value open_basedir "/home/example/public_html:/tmp"
   ```

3. #### Step 3: Save, and run the check again
   The `open_basedir:` line should show the longer list, and the folder should read "PHP can write to it: yes".
4. #### Step 4: Upload the file again
   It should arrive as it did before the message began.

**To undo it:** Put your copy of .htaccess back.

### Free space on the disk

- Takes care
- Low risk
- About 20 minutes

PHP shows this message when it cannot create the temporary file at all. A disk with no room for a new file stops it there, and so does an account that has used its allowance of space or of files. When PHP creates the file and runs out of room while filling it, the message is "Failed to write file to disk." instead.

1. #### Step 1: Check how full the account is
   Your hosting panel shows how much of your disk allowance is used. If it also shows a count of files, which it may call inodes, check that too.
2. #### Step 2: Or check from the command line
   Over SSH, the first command shows space and the second shows inodes, for the disk that holds the folder. Use the folder from the check in place of `/tmp`.
   bash Copy

   ```
   df -h /tmp
   df -i /tmp
   ```

3. #### Step 3: Remove what you no longer need
   Look first at backup archives kept on the server, old log files and copies of the site left over from a move. Download anything you might want before you delete it.
4. #### Step 4: If the full disk is not yours
   A temporary folder such as `/tmp` can be on a disk the whole server shares. Only the host can clear that one.

## When to get help

If the check shows a folder that exists, can be written to and has room, and uploads still fail with this message, the cause is somewhere PHP's own code cannot see. Finding it takes access to the server's configuration and logs. The same is true when the host says the folder is fine and the message stays.

## Common questions

Is "Failed to write file to disk." the same problem?

It is the next one along. PHP numbers its upload errors: 6 is "Missing a temporary folder" and 7 is "Failed to write file to disk." With 7, PHP created the temporary file and could not write the upload into it. Check free space first, then the folder, using the same file.

Why did it start when nothing on the site changed?

Because the setting is not on the site. Nothing in WordPress, a plugin or a theme chooses the folder an upload lands in. Ask what changed on the server: a move, a new PHP version, a setting edited in the hosting panel, or a disk that filled up.

Can I install a plugin or a theme while uploads are broken?

Yes. Unzip it on your computer and upload its folder over SFTP, into `wp-content/plugins/` or `wp-content/themes/`. It then appears in the dashboard, ready to activate. Files sent this way do not pass through PHP's upload folder. If an upload fails with a message about the file's size instead, the fix is raising PHP's upload limits (https://wpministry.co/errors/are-you-sure-you-want-to-do-this/). For an update that stopped halfway, use the runbook for a failed update (https://wpministry.co/resources/failed-wordpress-update-runbook/).

## More on this subject

- WordPress errors and troubleshooting: https://wpministry.co/topics/wordpress-troubleshooting/
- Guide How to update the PHP version of a WordPress site: https://wpministry.co/blog/update-php-version-wordpress/
- Guide WordPress uptime monitoring: what a check sees and what it misses: https://wpministry.co/blog/wordpress-uptime-monitoring/
- Glossary term .htaccess: https://wpministry.co/glossary/htaccess/
- Guide Locked out of WordPress admin: find which lockout you have and get back in: https://wpministry.co/blog/locked-out-of-wordpress-admin/
- Glossary term Must-use plugin (mu-plugin): https://wpministry.co/glossary/must-use-plugin/
- Glossary term Permalink: https://wpministry.co/glossary/permalink/

## Would you rather we fixed it?

Quick Fix is $49. One issue, one site, up to about an hour. No fix, no fee. 30-day warranty.

More about this work: One-time WordPress fix (https://wpministry.co/services/one-time-fix/)

May we measure how this site is used?

A yes notes the pages of this visit and loads Google Analytics. A no keeps and loads nothing. See the cookies page (https://wpministry.co/legal/cookies/).

If you say yes, we note the pages you look at during this visit and load Google Analytics. If you say no, nothing is kept and nothing is loaded. The site works the same either way. The cookies page (https://wpministry.co/legal/cookies/) has the details.

## Structured data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Organization",
      "@id": "https://wpministry.co/#organization",
      "name": "WP Ministry",
      "url": "https://wpministry.co/",
      "logo": "https://wpministry.co/brand/logo.png",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "1309 Coffeen Ave STE 1200",
        "addressLocality": "Sheridan",
        "addressRegion": "WY",
        "postalCode": "82801",
        "addressCountry": "US"
      },
      "sameAs": [
        "https://www.linkedin.com/company/wp-ministry/",
        "https://x.com/wpministryco",
        "https://www.instagram.com/wpministryco/",
        "https://www.facebook.com/wpministryco",
        "https://www.tiktok.com/@wpministryco",
        "https://www.pinterest.com/wpministryco/",
        "https://www.youtube.com/channel/UCOZRuAukk5QSTRPG6BaHl3Q"
      ]
    },
    {
      "@type": "WebSite",
      "@id": "https://wpministry.co/#website",
      "name": "WP Ministry",
      "url": "https://wpministry.co/",
      "inLanguage": "en-US",
      "publisher": {
        "@id": "https://wpministry.co/#organization"
      }
    },
    {
      "@type": "TechArticle",
      "@id": "https://wpministry.co/errors/missing-a-temporary-folder/#article",
      "headline": "How to fix \"Missing a temporary folder\" in WordPress",
      "description": "PHP could not create the temporary file every upload begins as. The folder is a PHP setting on the server, and defining WP_TEMP_DIR does not clear this message.",
      "url": "https://wpministry.co/errors/missing-a-temporary-folder/",
      "mainEntityOfPage": "https://wpministry.co/errors/missing-a-temporary-folder/",
      "inLanguage": "en-US",
      "image": "https://wpministry.co/og/errors/missing-a-temporary-folder.png",
      "author": {
        "@id": "https://wpministry.co/#organization"
      },
      "publisher": {
        "@id": "https://wpministry.co/#organization"
      },
      "datePublished": "2026-10-07T00:00:00.000Z",
      "dateModified": "2026-10-07T00:00:00.000Z"
    },
    {
      "@type": "BreadcrumbList",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://wpministry.co/"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Error fixes",
          "item": "https://wpministry.co/errors/"
        },
        {
          "@type": "ListItem",
          "position": 3,
          "name": "How to fix \"Missing a temporary folder\" in WordPress"
        }
      ]
    }
  ]
}
```