Fix “Missing a temporary folder” in WordPress
Case file
- Symptom
- Every upload fails with “Missing a temporary folder”; the rest of the site works
- Cause
- PHP has no usable temporary folder —
upload_tmp_dirand its fallbacks all point nowhere - Fix
- Point
upload_tmp_dirat a folder that exists, or create the folder it points at - Result
- The same upload succeeds and lands in the Media Library
The break · What you need · The diagnosis · The fix · Verify · If that didn’t work · What happened · Where this came from
The break
When a file is uploaded, PHP saves it in a temporary folder first, and only then does WordPress move it into the Media Library. If PHP cannot find a place to put the file — the temporary folder does not exist, or PHP cannot write to it — the upload stops before WordPress ever sees it, and the message is “Missing a temporary folder.” The usual trigger is a server move or a PHP version switch: the old server’s temporary folder path no longer exists on the new one, and nothing updated the configuration.
This guide reproduces the break first. A disposable install ran with PHP’s temporary folders all pointed at a folder that did not exist. An image upload failed with the message, and the same upload succeeded once a usable folder existed.
What you need
- Access to the server files and to
php.ini(SSH, SFTP, or your host’s PHP settings page). - Permission to create a folder on the server, or to ask the host to fix the setting.
- A test image to upload.
The diagnosis
1. Confirm the symptom
Try an upload in the Media Library and note the exact message. In the reproduction, the upload failed at once, while the homepage and wp-admin worked normally:
Output — upload with no usable temp folder
{"success":false,"data":{"message":"Missing a temporary folder.",
"filename":"srm-test-photo.jpg"}}
Key result: only uploads fail, and the message names a folder, not a file size. That rules out the upload-size limits — a file that is too big fails with a different message, about upload_max_filesize.
2. Find the temp folder PHP uses
PHP looks for a temporary folder in order: the folder set in upload_tmp_dir, then the system temp folder, then /tmp. The error appears only when every one of those fails. That matters, because it means a single wrong setting often does not reproduce the error — the reproduction proved that too. With only upload_tmp_dir pointed at a folder that did not exist, the upload still succeeded: PHP fell back to the system temp folder. The error only appeared once upload_tmp_dir, sys_temp_dir, and the TMPDIR environment variable all pointed at the same nonexistent folder.
Check what your server actually uses. On the command line, php -i | grep upload_tmp_dir shows the configured value — but check the value for web requests, not the command line, because hosts often configure the two differently.
Key result: every fallback folder is missing or unusable. That is the whole diagnosis — PHP has nowhere to put the file, so the upload fails before WordPress starts.
The fix
3. Point the temp folder at a real folder
Set upload_tmp_dir in php.ini to a folder that exists and that PHP can write to, then restart or reload PHP so the change takes effect:
Code — php.ini
upload_tmp_dir = "/tmp"
On the test server the same change was made by restarting PHP with upload_tmp_dir=/tmp. The same upload then succeeded and the image landed in the Media Library.
4. Or create the folder it already points at
If php.ini already points at a folder that simply does not exist — deleted in a migration, or never created on the new server — create it. But 755 on its own does not make a folder writable by PHP: 755 lets the folder's owner write, so the folder must be owned by the user PHP runs as. Check the owner first:
Command — who owns the folder
ls -ld /path/to/tmp
On shared hosting PHP usually runs as your account user; on a VPS it is often www-data. If the folder is owned by someone else, change the owner — or ask the host to:
Command — create the missing folder, owned by the PHP user
mkdir -p /path/to/tmp
chown www-data:www-data /path/to/tmp
chmod 755 /path/to/tmp
Replace www-data with the user PHP runs as on your server. In the reproduction the test server ran as the folder's owner, so 755 alone was enough there — and creating the folder the configuration already pointed at made the same upload succeed at once, with no configuration change at all. On a host where PHP runs as a different user, the ownership is what decides it, not the 755.
Trap: WP_TEMP_DIR in wp-config.php does not fix this. That constant changes the folder WordPress uses for its own downloads — plugin and theme packages, updates — but PHP saves a browser upload before WordPress starts, so the constant has no effect on it. The reproduction proved that: with WP_TEMP_DIR set to a valid folder and the PHP temp folders still broken, the upload still failed with “Missing a temporary folder.” The fix lives in PHP’s settings, not in wp-config.php.
Verify the fix
Upload the same file again and check it lands in the Media Library. In the reproduction both fixes were verified with the same 8 KB test image:
| Step | Upload result |
|---|---|
Only upload_tmp_dir broken | Upload succeeds — PHP falls back to the system temp folder |
| All temp folders broken | “Missing a temporary folder.” |
| After creating the folder | Upload succeeds, attachment created |
After upload_tmp_dir = /tmp | Upload succeeds, attachment created |
With WP_TEMP_DIR set, PHP folders still broken | “Missing a temporary folder.” — the constant does not help |
If that didn’t work
Check the folder is writable by PHP
A folder that exists but PHP cannot write to produces the same error. Check the permissions — 755 on the folder — and the ownership: the folder must be writable by the user PHP runs as, which on shared hosting is your account user and on a VPS is often www-data. A folder owned by the wrong user with the right-looking permissions still fails.
If you cannot edit php.ini
On shared hosting the PHP configuration may be locked. Use the host’s PHP settings page (cPanel’s MultiPHP INI Editor, or the equivalent) to set upload_tmp_dir, or ask the host to fix it — the setting is theirs to change, and a migration that breaks it is theirs to repair.
What happened
PHP had no usable temporary folder: upload_tmp_dir and its fallbacks all pointed at a folder that did not exist, so every upload failed with “Missing a temporary folder” before WordPress ever saw the file. Creating the folder the configuration pointed at — and separately pointing upload_tmp_dir at /tmp — both made the same upload succeed.
Where this came from
- Error code 6,
UPLOAD_ERR_NO_TMP_DIR, meaning “Missing a temporary folder” — and error code 1, the upload-size error — come from Error Messages Explained — The PHP Manual. upload_tmp_dirbeing the temporary directory used for file uploads, which must be writable by the PHP user, and PHP falling back to the system default when it is not writable, come from Description of core php.ini directives — The PHP Manual.