You drag an image into the WordPress media library, the progress bar crawls along, and then you get this: "Missing a temporary folder." No file uploaded, no plugin named, no hint about what to do next. It looks scary, but it's one of the more straightforward upload errors to fix once you know where PHP keeps its scratch files.

What the error actually means

When a browser uploads a file, PHP doesn't write it straight into wp-content/uploads. It first drops it in a temporary directory, then WordPress moves it into place. If PHP can't find or write to that temporary directory, it raises upload error code 6 (UPLOAD_ERR_NO_TMP_DIR), and WordPress shows the message above.

So the problem is never your image. It's the scratch folder PHP is trying to use.

Common causes

CauseHow it shows up
upload_tmp_dir points to a folder that doesn't existStarted after a migration or server move
The temp folder exists but isn't writable by your accountStarted after a permissions "clean-up"
The temp folder is on a full partition or over quotaOther things (backups, email) start failing too
A leftover php.ini or .user.ini from an old hostPath like /home/olduser/tmp that no longer exists
nginx-primary-script-unknown-file-not-found-on-a-vps" class="auto-link">PHP-FPM pool with a private /tmp that was removedVPS only, after a systemd or OS update

Fix on cPanel hosting

1. Check what PHP thinks the temp folder is

Create a file called tmpcheck.php in your site root with this content, open it in a browser, then delete it straight away:

<?php
echo 'upload_tmp_dir: ' . ini_get('upload_tmp_dir') . "\n";
echo 'sys_get_temp_dir: ' . sys_get_temp_dir() . "\n";
echo 'writable: ' . (is_writable(sys_get_temp_dir()) ? 'yes' : 'NO');

If upload_tmp_dir is empty, PHP uses the system default, usually /tmp. If it shows a path that isn't yours, that's your culprit.

2. Look for a stray override

In File Manager (enable "Show Hidden Files"), check your public_html folder and the folder above it for these files:

  • .user.ini
  • php.ini
  • .htaccess (look for php_value upload_tmp_dir)

If you find an upload_tmp_dir line pointing somewhere that doesn't exist, remove it or correct it. Also check MultiPHP INI Editor in cPanel, since the value can be set there too.

3. Create a temp folder you control

If you'd rather set it explicitly, make a private folder outside the web root:

mkdir -p ~/tmp
chmod 750 ~/tmp

Then add this to .user.ini in public_html (adjust the username):

upload_tmp_dir = /home/yourusername/tmp

Give it a minute or two, since PHP caches .user.ini for a short while, then retry the upload.

4. Rule out disk quota

In cPanel, open Disk Usage. If you're at 100%, PHP can't write the temp file even though the folder is fine. Clear old backups or logs first, then retry. Our disk quota guide walks through what to delete safely.

Fix on a VPS

On your own server you have more moving parts. Work through these in order.

  1. Check /tmp exists and has the right mode. It should be drwxrwxrwt (1777):
    ls -ld /tmp
    sudo chmod 1777 /tmp
  2. Check free space and inodes.
    df -h /tmp
    df -i /tmp
  3. Find the configured value.
    php -i | grep -E 'upload_tmp_dir|sys_temp_dir'
    grep -R "upload_tmp_dir" /etc/php* 2>/dev/null
  4. Check for PrivateTmp. If PHP-FPM runs with PrivateTmp=true, it gets its own /tmp. After some updates, that directory can go missing. Restarting fixes it:
    sudo systemctl restart php8.3-fpm
    Swap in your actual PHP version and service name.
  5. On SELinux systems (AlmaLinux, Rocky), a wrong context on a custom temp folder will block writes even if permissions look right. Run ls -Z on the folder and compare it to /tmp.

Still stuck? Test outside WordPress

If the error persists after these changes, confirm whether it's PHP or WordPress. Upload a small file through a plain PHP form, or try File Manager upload. If File Manager works but WordPress doesn't, look at plugins that change upload handling (security plugins, image optimisers, offload-to-S3 plugins). Temporarily deactivate them and test again.

Also check wp-config.php for a line like define('WP_TEMP_DIR', ...). WordPress uses that constant for its own temp work, and a path left over from an old server will cause trouble too.

Prevention

  • After any migration, search for hard-coded paths in .user.ini, .htaccess and wp-config.php.
  • Don't "tidy up" the home directory by deleting a tmp folder you didn't create. Some cPanel setups use it.
  • Keep an eye on disk usage. Uploads fail in odd ways when the account is nearly full.
  • Don't set an upload_tmp_dir unless you have a reason to. The default works for most sites.

Rule of thumb: if the error appeared right after a move, a PHP version change or a permissions change, the temp path is almost always the thing that changed.

Frequently Asked Questions

Is "Missing a temporary folder" a WordPress bug?

No. WordPress is just passing along an error from PHP. The cause is the server's temp directory setting or its permissions, not WordPress core.

Can I fix it with a plugin?

Not really. Plugins run after PHP has already failed to store the file. You need to fix the PHP configuration or the folder itself.

It only fails for large files. Is it the same problem?

Probably not. Large-file failures usually come from upload_max_filesize or post_max_size. This error happens even with tiny images because PHP can't write any temp file at all.

Should the temp folder be inside public_html?

No. Keep it outside the web root, such as /home/yourusername/tmp, so uploaded files in transit are never reachable from a browser.

I fixed it but the error is still there. Why?

PHP caches .user.ini for a few minutes, and PHP-FPM needs a restart after changes to the main config. Wait a bit, restart the service on a VPS, and clear any caching plugin before testing again. If it still fails, our support team can check it from the server side.