ERROR · 34 · VERIFIED 2026-10allwpcare.com/errors/missing-a-temporary-folder/
Errors / missing-a-temporary-folder

Missing a Temporary Folder

PHP has no folder it can write an upload to. Make /tmp or upload_tmp_dir writable in php.ini. WP_TEMP_DIR in wp-config.php does not fix it.

The message you see
1−Missing a temporary folder.
Last verified Oct 2026Tested with WordPress 7.1Applies to WordPress 7.1 (tested) · PHP 7.4+

Why it happens

  • PHP could not use the folder set as upload_tmp_dir in php.ini, and it could not use the system temporary folder (usually /tmp) either. Typical reasons: the folder was deleted, it has the wrong owner or mode, or a host change left a path from the old server.
  • A system temporary folder that PHP cannot write to causes this when upload_tmp_dir is unusable too (not set, or pointing at a folder that does not exist). On my test site I needed both to be broken.
  • The second message, "Failed to write file to disk.", means PHP found a folder but could not write the file into it. The usual reasons are a full disk or a full hosting quota. I could not reproduce this one in my lab, so it comes from the PHP manual only.

How to fix it

Try the fixes in this order. Each one is independent: stop as soon as the error is gone.

FIX 01

Find out which folders PHP can really use

  1. Ask PHP as the website, not as yourself. WP-CLI and SSH can show a different PHP setup than your site does.
  2. Create a file called tmpcheck.php in your site folder with the check shown under "Check what PHP can use" further down this page, open it in a browser, and delete it straight away.
  3. Read the two lines it prints. If both say writable: no, that is this error. (not set) for upload_tmp_dir is normal. Then only the system temporary folder matters.
FIX 02

Make the system temporary folder writable

  1. On a server you manage, /tmp should be owned by root with mode 1777, which means everyone may write and nobody may delete other people's files. Check with ls -ld /tmp. It should print drwxrwxrwt.
  2. Fix it with sudo chmod 1777 /tmp. I set /tmp to 755 to cause the error, set it back to 1777, and the same upload worked with no other change.
  3. On shared hosting you cannot change /tmp. Go to the next fix, or ask your host.
FIX 03

Point upload_tmp_dir at a folder PHP can write in

  1. Make a folder outside the web root, owned by PHP's user. For example: sudo mkdir /var/www/phptmp && sudo chown www-data:www-data /var/www/phptmp && sudo chmod 700 /var/www/phptmp. Use your PHP user in place of www-data.
  2. Add upload_tmp_dir = /var/www/phptmp to php.ini, or in a file next to it in the PHP conf.d folder, then restart Apache or PHP-FPM. On my test site, with /tmp still locked, this alone made the upload work.
  3. On shared hosting, look for PHP settings, MultiPHP INI Editor or Select PHP version → Options in your hosting panel. Some hosts show upload_tmp_dir there. If yours does not, ask them to set it.
  4. upload_tmp_dir cannot be set with ini_set(). I tried it and it returned false. The PHP manual lists it as INI_SYSTEM, which means php.ini or server config only. A .user.ini file will not work either.
FIX 04

Do not use WP_TEMP_DIR for this

  1. Many guides say to add define( 'WP_TEMP_DIR', ... ) to wp-config.php. It does not fix this message. WordPress is not in charge of the folder: PHP saves the upload before WordPress starts.
  2. I added WP_TEMP_DIR pointing at a folder while PHP's temporary folders were broken. get_temp_dir() returned the new folder, and the upload still failed with "Missing a temporary folder." Remove the line again unless you need it for something else.
FIX 05

If the message says Failed to write file to disk

  1. PHP found a temporary folder and started writing, then the write failed. The usual reasons are no space left on the disk, or no space left in your hosting account (the quota).
  2. Check free space and quota in your hosting panel, or run df -h /tmp and df -h for the folder in upload_tmp_dir on a server you manage. Also check inodes with df -i.
  3. I could not make this message happen in my lab, so I cannot show you the fix working. Free some space, or ask your host to raise the quota, then upload again.
FIX 06

Ask the host when the folders look right

  1. If the check above shows writable folders and the error still comes, open_basedir may be hiding the system temporary folder from PHP. The PHP manual says that when open_basedir is on, the default temporary folder must be allowed for uploads to work.
  2. Send them the exact message, the date, and the output of the check from the first fix.

PHP could not store your upload anywhere before WordPress even saw it. Make the system temporary folder (/tmp) writable, or set upload_tmp_dir in php.ini to a folder PHP can write in. Adding WP_TEMP_DIR to wp-config.php, which many guides suggest, does not help, and below I show why.

What you see#

The message appears under the file name on Media → Add Media File, in the media library window, and in the block editor when you add an image. A Plupload upload (the normal drag and drop one) shows it like this:

The Upload Media screen. A red notice reads: pic.png has failed to upload. Missing a temporary folder.
Media, Add Media File on WordPress 7.1.4, with no folder PHP could write temporary files in.

The same text comes back from the REST API, which the block editor uses. The upload request answers with status 500:

Output
{"code":"rest_upload_unknown_error","message":"Missing a temporary folder.","data":{"status":500}}

How it works#

PHP handles an upload before any WordPress code runs. It writes the file to a temporary folder and tells the script where it is. WordPress then checks PHP's error code and, if the code is above zero, turns it into a sentence. In wp_handle_upload() the list holds more entries than the ones below. These are the ones that matter here:

Output
UPLOAD_ERR_INI_SIZE    = 1  ->  The uploaded file exceeds the upload_max_filesize directive in php.ini.UPLOAD_ERR_PARTIAL     = 3  ->  The uploaded file was only partially uploaded.UPLOAD_ERR_NO_FILE     = 4  ->  No file was uploaded.UPLOAD_ERR_NO_TMP_DIR  = 6  ->  Missing a temporary folder.UPLOAD_ERR_CANT_WRITE  = 7  ->  Failed to write file to disk.UPLOAD_ERR_EXTENSION   = 8  ->  File upload stopped by extension.

I made that table by calling wp_handle_upload() on WordPress 7.1.4 with each error code. For 7 this shows what WordPress prints, not a real disk failure.

Stacked steps. 1: the browser sends the file and PHP saves it as a temporary file. 2: PHP tries upload_tmp_dir, then the system temp folder. 3A: if neither works, code 6 and the message Missing a temporary folder. 3B: if the write fails, code 7 and Failed to write file to disk. 4: otherwise WordPress moves the file into uploads. A dashed box says WP_TEMP_DIR is not part of this path.
The error is decided in step 2 and 3, inside PHP. WordPress only translates the code.

A wrong upload_tmp_dir alone is not enough#

I expected a missing upload_tmp_dir to cause the error. It did not. I set upload_tmp_dir=/nonexistent/tmp in php.ini, restarted Apache, and uploads kept working. PHP logged a notice and used the system temporary folder instead:

Output
PHP Notice:  PHP Request Startup: file created in the system's temporary directory in Unknown on line 0

The PHP manual says the same: if the folder in upload_tmp_dir is not writable, PHP falls back to the system default. A folder that exists but belongs to root, with mode 755, behaved the same way.

I got the error only when both folders were unusable: upload_tmp_dir=/nonexistent/tmp and /tmp owned by root with mode 755. Then PHP logged:

Output
PHP Warning:  File upload error - unable to create a temporary file in Unknown on line 0
upload_tmp_dirSystem temp folder (/tmp)Result on my test site
Not setWritableUpload works
Folder does not existWritableUpload works, notice in the PHP log
Folder exists, PHP cannot writeWritableUpload works, notice in the PHP log
Folder does not existNot writable"Missing a temporary folder."
Folder PHP can write inNot writableUpload works

So if you see this error, the system temporary folder is broken as well, even when upload_tmp_dir is the setting you recognise. Fix either one.

Why WP_TEMP_DIR does not fix it#

get_temp_dir() is WordPress's own answer to "where may I put a temporary file?". WordPress uses it for downloads, such as plugin zips and update packages. The lookup order in WordPress 7.1.4 is WP_TEMP_DIR if defined, then sys_get_temp_dir(), then upload_tmp_dir, then wp-content/, then /tmp/. It is a different folder, in a different program, at a different time. It never changes where PHP puts an upload.

I tested both halves with /tmp locked and upload_tmp_dir broken:

Terminal
wp config set WP_TEMP_DIR /var/www/tmpwp --type=constantwp eval 'echo get_temp_dir();'
Output
/var/www/tmpwp/

The upload from Media → Add Media File still answered "Missing a temporary folder." The other half, installing a plugin with /tmp locked and no WP_TEMP_DIR, worked, because get_temp_dir() fell back to wp-content/:

Terminal
wp eval 'echo get_temp_dir(), " / ", sys_get_temp_dir();'wp plugin install hello-dolly --force
Output
/var/www/html/wp-content/ / /tmpSuccess: Installed 1 of 1 plugins.

So a locked /tmp breaks uploads only. Plugin and theme installs from the dashboard keep working. That is a useful clue when you decide whether this is your problem.

Failed to write file to disk#

The second message belongs to the same step. PHP found a folder, but the write failed. The PHP manual describes it as UPLOAD_ERR_CANT_WRITE, value 7, "Failed to write file to disk." The usual reasons are a full disk or a full account quota. This part is quoted from the PHP manual and not reproduced: my lab cannot fill a disk or mount a small one.

Making the folder read-only did not cause this message. It gave "Missing a temporary folder.", because PHP could not even create the file.

Check what PHP can use#

This is the file from the first fix. Run it through the website, not WP-CLI, and delete it afterwards:

tmpcheck.php
<?phpheader( 'Content-Type: text/plain' );$dirs = array( 'upload_tmp_dir (php.ini)' => ini_get( 'upload_tmp_dir' ), 'system temp folder' => sys_get_temp_dir() );foreach ( $dirs as $label => $dir ) {	printf( "%-26s %-18s exists: %-3s writable: %s\n", $label, $dir ?: '(not set)', is_dir( $dir ) ? 'yes' : 'no', is_writable( $dir ) ? 'yes' : 'no' );}

On my broken test site it printed:

Output
upload_tmp_dir (php.ini)   /nonexistent/tmp   exists: no  writable: nosystem temp folder         /tmp               exists: yes writable: no

Does Site Health show it?#

No. I searched wp-admin and wp-includes in 7.1.4 for upload_tmp_dir and the temp folder checks. Site Health has one writable-folder test, for wp-content/upgrade-temp-backup, and nothing for PHP's temporary folder. See Site Health explained for what it does cover.

If the temporary folder is fine, a failed upload usually ends in another message. For files that are too large, see the file exceeds the maximum upload size for this site. For a file PHP stops for size, see the uploaded file exceeds the upload_max_filesize directive. For a folder that exists but cannot be written, see the uploaded file could not be moved to wp-content/uploads.

Sources

  1. PHP manual: Error Messages Explained (file uploads) · the list of upload error codes
  2. PHP manual: Predefined constants, UPLOAD_ERR_NO_TMP_DIR and UPLOAD_ERR_CANT_WRITE · codes 6 and 7 and their wording
  3. PHP manual: php.ini core directives, upload_tmp_dir · INI_SYSTEM; falls back to the system default; open_basedir note
  4. WordPress core source: wp_handle_upload() in wp-admin/includes/file.php · the function wp_handle_upload() maps PHP's error code to the message text (read in 7.1.4)
  5. get_temp_dir() · WordPress's own temporary folder and WP_TEMP_DIR
Newsletter

One email when something breaks or changes.

New plugins and re-tested guides, about twice a month. Never a sales pitch.