Troubleshooting · Troubleshooting
How to Fix "Missing a Temporary Folder" in WordPress
Short answer
Fix the error by giving PHP a writable temporary folder. Set upload_tmp_dir in php.ini or through your host panel, then test a small upload in the Media Library. WP_TEMP_DIR in wp-config.php helps WordPress downloads, but it does not always fix browser uploads, so ask your host if the error stays.
Key takeaways
- The message is PHP upload error 6, UPLOAD_ERR_NO_TMP_DIR, and it means PHP could not create a temporary file.
- PHP reads upload_tmp_dir before WordPress loads, so a browser upload can fail even when WordPress settings look fine.
- WP_TEMP_DIR in wp-config.php sets the folder WordPress uses for its own downloads, such as plugin and theme packages.
- upload_tmp_dir is an INI_SYSTEM setting, so it must be set in php.ini or the server configuration, not in a script.
- If the folder is missing, unwritable, full, or blocked by open_basedir, uploads stop with the same message.
- When you cannot edit PHP settings, your host must fix upload_tmp_dir, the folder permissions, or the disk space.
What does “Missing a Temporary Folder” mean in WordPress?
It means PHP could not find a writable folder to hold your file for a moment before WordPress moves it to its final place.
When you upload an image, a plugin zip, or a theme zip, PHP first saves the file in a temporary folder. WordPress then moves it to wp-content/uploads or to the plugin and theme folders. If that first save fails, the upload stops.
The PHP manual lists this as upload error code 6, UPLOAD_ERR_NO_TMP_DIR, with the text “Missing a temporary folder” (PHP file upload errors). Code 7 is different: it is “Failed to write file to disk” and means PHP created the file but could not finish writing it.
A temporary folder is a scratch folder on the server. It holds files only while they are being received or processed, then WordPress or PHP moves or deletes them. The folder is not a WordPress dashboard setting, so no dashboard option can point WordPress at a new one.
Why does WordPress show this error instead of uploading the file?
WordPress shows it because PHP reports the failure before WordPress has a file to work with.
PHP handles the first part of every browser upload. It streams the file from your browser into a new file in its temporary folder and records the result as a number. WordPress reads that number and prints the matching sentence, so the message reports a PHP failure, not a WordPress bug.
That order matters for the fix. A setting that WordPress reads after it loads cannot change what PHP already tried to do. This is why the popular wp-config.php fix helps some tasks and not others, as explained below.
The error can also stop plugin and theme updates. A related upload failure is covered in How to Fix the HTTP Error When Uploading Images in WordPress.
What are the most likely causes of this error?
The most likely cause is a missing or unwritable PHP temporary folder after a move, a PHP version change, or a server change.
The folder named in upload_tmp_dir may not exist. It may exist but the PHP user may not have write access to it. The disk or the account quota may be full, so PHP cannot create a new file even when the folder is there.
A path rule called open_basedir may also block PHP from reaching the folder. A wrong WP_TEMP_DIR value can add to the problem for WordPress downloads, if a developer set it to a path from an old host and the folder was later removed.
| Cause | Where it lives | What you see |
|---|---|---|
| upload_tmp_dir empty or points to a missing folder | php.ini or server PHP settings | Every upload fails with the same message |
| Temp folder exists but PHP cannot write to it | Folder owner or permissions | Uploads fail even though the path looks right |
| Disk or quota full | Server storage | Uploads fail and other saves may fail too |
| open_basedir blocks the temp folder | PHP settings | Uploads fail after a server or PHP change |
| Wrong WP_TEMP_DIR path | wp-config.php | Plugin, theme, and update downloads fail |
Start with the cause that matches your timing. If the error began right after a move or a PHP change, check the PHP settings first. If it began after you edited wp-config.php, check that file first.
How do you check which temp folder PHP is using?
Check the live PHP settings for your site, not the settings on your own computer or a different site.
In the dashboard, go to “Tools” then “Site Health” and open the “Info” tab. Expand the “Server” section and note the PHP version and the server details shown there. Site Health reports what WordPress is running on, so it is the right place to start.
If you have panel access, look for the PHP settings screen your host provides. On cPanel, the path is “MultiPHP INI Editor” in the “Software” section. That screen shows the PHP directives for the version your site uses.
Ask your host for the current values if you cannot see them. Send the exact error, the time it happened, and the file type you tried to upload.
Ask them to confirm upload_tmp_dir, sys_temp_dir, open_basedir, free disk space, and the folder owner. If your host changed the PHP version recently, mention it, because that change may have reset the temp path. For steps after a version change, see How to Update PHP for WordPress Without Breaking the Site.
How do you fix it with WP_TEMP_DIR in wp-config.php?
WP_TEMP_DIR gives WordPress its own temporary folder for downloads, and it is the easiest fix you can try yourself.
WordPress reads this constant first in its get_temp_dir() function, as shown in the WordPress get_temp_dir() reference. If WP_TEMP_DIR is set, WordPress returns that folder. If it is not set, WordPress tries sys_get_temp_dir(), then upload_tmp_dir from php.ini, then WP_CONTENT_DIR, then /tmp/.
The same reference notes that sys_get_temp_dir() honors the TMPDIR environment variable. Use WP_TEMP_DIR when plugin, theme, or core downloads fail, or when you want WordPress to use a folder you control.
It does not change the folder PHP uses for a browser upload, because PHP has already tried to save that upload before WordPress loads wp-config.php. Try it first because it is fast, but do not stop there if Media Library uploads still fail.
Steps to add WP_TEMP_DIR
- Back up your site before you edit any file. A backup lets you restore the site if a typo breaks it, and the How to Back Up WordPress guide shows the options.
- Open your site files with FTP or your host file manager and find wp-content.
- Create a new folder inside wp-content and name it temp.
- Set that folder to 755 so the server user can write to it. Do not use 777, because that makes the folder writable by any user on a shared server.
- Open wp-config.php in the site root. The WordPress wp-config.php handbook says this file sits in the root and holds base configuration such as database details, and it advises backups before you change it.
- Add this line above the line that says “That is all, stop editing!”:
define( 'WP_TEMP_DIR', dirname( __FILE__ ) . '/wp-content/temp/' );
- Save wp-config.php, then test a plugin download or a small Media Library upload. If downloads work but browser uploads still fail, the PHP upload folder is still the problem.
How do you set upload_tmp_dir in php.ini or cPanel?
Set upload_tmp_dir at the server level, because PHP only accepts this setting in php.ini or the server configuration.
The PHP manual lists upload_tmp_dir with a default of NULL and a changeable mode of INI_SYSTEM (PHP core php.ini directives). INI_SYSTEM means the setting can be set in php.ini or the web server configuration, not in a script, a .user.ini file, or .htaccess.
A value set in one of those other places is ignored, which is why some fixes that look right change nothing. cPanel support gives the same rule: upload_tmp_dir can only be changed in the INI_SYSTEM context, so it must be in php.ini or httpd.conf (cPanel: Changing the PHP upload_tmp_dir).
The same cPanel article says the MultiPHP Manager can change it because it edits both user and system values. With PHP-FPM, the value must be changed through the PHP-FPM pool configuration.
Steps on cPanel
- Log in to cPanel and open “MultiPHP INI Editor” in the “Software” section.
- Choose the home directory or the domain document root for the site with the error.
- Switch to the “Editor Mode” tab if you need to add a line that Basic Mode does not show.
- Add or edit this line, using a folder that exists on your account:
upload_tmp_dir = /tmp
- Save the change, then restart PHP if your host panel asks you to do so. Some hosts apply the change at once, while others need a PHP-FPM restart.
cPanel support also states the default: PHP uses /tmp as the upload path by default, and the standard workflow uploads a file to /tmp and then moves it into the site upload path (cPanel: How to change the PHP upload path).
If /tmp is missing, full, or blocked, point upload_tmp_dir at a folder inside your own account instead, and make sure that folder exists and is writable.
If you run a VPS or a dedicated server, edit the active php.ini file for the PHP version your site uses. After you save it, restart PHP-FPM or Apache, then check the setting again.
How do you check permissions, disk space, and open_basedir?
Check all three, because each one can produce the same short error on its own.
First, check the folder owner and permissions. The temp folder must be owned by the same user that runs PHP for your site, or at least writable by that user. A folder set to 755 works when the owner is right, while a folder owned by a different user can still fail at 755.
Second, check disk space and quota. A full disk stops PHP from creating any new file, and a full account quota does the same even when the server disk has room. Look at the host panel storage meter first.
Third, check open_basedir. WordPress support explains that upload_tmp_dir must point to an existing directory and that open_basedir should contain it or a directory that contains it (WordPress support: Temp Folder).
If open_basedir lists only your home directory and the temp folder sits outside it, PHP cannot reach the folder.
Your host must add the temp folder to that list or move the temp folder inside it. A directory that cannot be created also blocks installs, and How to Fix the WordPress “Could Not Create Directory” Error covers that message in detail.
How do you know the fix worked?
Upload a small image in the Media Library and watch for a clean result with no error message.
Use a small JPEG under 1 MB for the first test, so file size does not confuse the result. Go to “Media” then “Add New” in the dashboard, upload the file, and open it in the library. If the image shows a thumbnail and you can insert it into a post, the upload path works.
Then test a plugin or theme download from the dashboard. Open “Plugins” then “Add New”, search for a plugin, and install it. If the install completes, WordPress can use its temp folder for downloads too.
If the error returns after a short time, check the folder again. A temp folder that fills up with old files can fail again, and a host change can reset upload_tmp_dir. Note the date and the exact step that failed, because your host will ask for it.
When should you contact your host?
Contact your host when you cannot edit php.ini, when the error affects every site on the account, or when the WP_TEMP_DIR fix did not help.
WordPress support replies on this error say the same thing: a missing temporary folder points to a problem with the server PHP settings, so reach out to the hosting provider for help (WordPress support: Missing Temporary Folder). On shared hosting, you often cannot change upload_tmp_dir yourself.
Send the host a short message with 5 facts: the exact error text, the URL of the page where it appears, the file type and size you tried, the PHP version from Site Health, and the steps you already tried.
Ask them to check upload_tmp_dir, sys_temp_dir, open_basedir, folder ownership, folder permissions, and free disk space in that order.
If the same error appears on all sites on the same account at the same time, say so in the first line. That pattern points to a server change rather than a single site.
What mistakes should you avoid?
Avoid the mistakes that waste time or make the site less safe.
- Do not set the temp folder to 777 and leave it that way. It makes the folder writable by any user on a shared server, so use 755 and fix the owner instead.
- Do not edit the wrong php.ini file. The command-line php.ini is not the one your site uses, so confirm the active file in your host panel first.
- Do not set upload_tmp_dir in .htaccess or .user.ini and expect it to work. PHP ignores INI_SYSTEM settings in those places.
- Do not keep adding WP_TEMP_DIR lines in different places. One line above the stop-editing line is enough, and a second line can hide a typo in the first.
- Do not skip the backup before you edit wp-config.php. A single missing quote in that file can take the whole site down.
- Do not assume the error is a plugin conflict. Deactivating plugins does not change the PHP temp folder, so test an upload first and check the PHP settings before you change plugins.
Frequently asked questions
Does the Missing a Temporary Folder error mean WordPress is broken?
No. It means PHP could not find or write to a temporary folder when it tried to receive your file. WordPress itself is usually fine, and the site pages keep working. The fix is in the PHP settings or the temp folder, not in a WordPress update or a theme change.
Why did WP_TEMP_DIR not fix my Media Library upload?
WP_TEMP_DIR sets the folder WordPress uses for its own downloads, such as plugin and theme packages. A Media Library upload is handled by PHP before WordPress loads, so PHP needs a working upload_tmp_dir or system temp folder. If that PHP folder is missing or blocked, WP_TEMP_DIR cannot help, and your host must fix the PHP setting.
Can I use /tmp as the temporary folder?
Yes, if /tmp exists on your server, is writable by the PHP user, and is allowed by open_basedir. cPanel support notes that PHP uses /tmp as the default upload path. On some shared servers /tmp is shared or restricted, so a folder inside your own account can be safer. Ask your host which path they recommend.
Is it safe to set the temp folder to 777?
No, not as a lasting fix. A 777 folder is writable by any user on a shared server, which is a security risk. Use 755 and make sure the folder is owned by the user that runs PHP for your site. If 755 does not work, the owner is usually wrong, so ask your host to correct it instead of opening the folder to everyone.
What should I tell my host when I ask for help?
Give them the exact error text, the page where it appears, the file type and size you tried, the PHP version from Site Health, and the steps you already tried. Ask them to check upload_tmp_dir, sys_temp_dir, open_basedir, folder ownership, folder permissions, and free disk space. That list covers the most likely causes in one message.
Will this error come back after I fix it?
It can return if the temp folder fills up, if disk space runs out, or if a host change resets upload_tmp_dir. Test a small upload after any PHP version change or site move. If the error returns on every site on the account at the same time, contact your host at once, because that points to a server change.
Sources
- Error Messages Explained PHP Manual
- Description of core php.ini directives PHP Manual
- get_temp_dir() WordPress Developer Resources
- Editing wp-config.php WordPress.org
- How to change the PHP upload path cPanel Support
- Changing the PHP upload_tmp_dir for a domain is not working cPanel Support
- How To Fix the Missing a Temporary Folder Error in WordPress Kinsta
- Temp Folder - Need more helps WordPress.org Support
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
