How to Fix WordPress Upload Failed to Write File to Disk Error
define('WP_TEMP_DIR', dirname(__FILE__) . '/wp-content/temp/'); above "That's all, stop editing!" in wp-config.php, create the wp-content/temp folder with 755 permissions, and retry the upload. Also check your disk quota and the permissions on wp-content/uploads/. The full steps are below.What Failed to write file to disk means
When you upload an image through Media, then Add New — or import any file through the WordPress dashboard — the file does not go straight into wp-content/uploads/. PHP first stages it in a temporary directory (the upload_tmp_dir setting in the server's PHP configuration), and only then does WordPress move the finished file into your uploads folder.
The "Failed to write file to disk" message means that first write failed: WordPress asked the server to save the temporary copy, and the server could not. The site itself keeps working — this error only blocks new uploads, which is why it usually shows up out of nowhere right after a hosting change or a PHP update changed something underneath you.
Common causes
- A missing or unwritable PHP temp folder: the
upload_tmp_dirpath in the server's PHP configuration does not exist or the web server cannot write to it — the single most common trigger, especially after a server move or PHP version upgrade. - A full disk or a hit storage quota: PHP cannot stage an upload anywhere when there is no free space left. Automatic backups often count against the quota and fill the disk silently.
- Wrong permissions on wp-content/uploads: folders should normally be 755 and files 644. A migration or restore can reset ownership so the web server user can no longer write to the uploads folder.
- A stale temp path after migration: the previous server's temp directory path was baked into the PHP configuration; on the new host that path does not exist, so every upload fails the moment you switch hosts.
- A broken php_value override in .htaccess: some setups force PHP settings through
.htaccess. A leftoverphp_value upload_tmp_dirline pointing at an old or invalid path overrides the working server default.
How to fix Failed to write file to disk — step by step
The whole fix takes about twenty minutes and is a one-line change in wp-config.php plus a folder you create once.
- Confirm the error and check your server disk space. Go to Media, then Add New in the WordPress dashboard and try the upload once — the message "Failed to write file to disk" appears below the file name. Then log in to your hosting panel and check your disk usage: a full disk or a hit storage quota is the most common trigger, because PHP cannot stage an upload anywhere when there is nowhere left to write.
- Check the permissions on wp-content/uploads. In cPanel File Manager or an FTP client, look at
wp-content/uploads. Folders should normally be 755 and files 644, and the uploads folder itself must be writable by the web server user. Wrong permissions after a migration or restore silently block every upload, so correct them and retest before touching anything else. - Point WordPress at a temp folder it controls. Open
wp-config.phpand add this line above the "That's all, stop editing!" comment:define('WP_TEMP_DIR', dirname(__FILE__) . '/wp-content/temp/');. This tells WordPress to stage uploads in a folder you own instead of the server's PHP temp directory, which is often missing or unwritable on shared hosting after a server move. - Create the temp folder and set its permissions. In File Manager or FTP, create a folder named
tempinsidewp-content, so the path iswp-content/temp. Set its permissions to 755. The folder must exist before the next upload attempt — WordPress does not create it automatically, and the error will continue until a writable folder is there. - Free up disk space if the quota is full. If the hosting panel shows your disk space is maxed out, delete or move old backup archives, staging copies, and unused media. Many plans count automatic backups against your quota. After clearing space, return to Media, then Add New and try the upload again.
- Retry the upload, then ask your host about PHP's temp directory. Upload a test file from Media, then Add New. If it lands in the library, the fix is complete. If the error persists, open a support ticket and ask the host to check PHP's
upload_tmp_dirsetting — on some setups only the host can repair a broken server-level temp path, especially after a server migration or PHP version change.
Did this fix it? Quick checklist
WP_TEMP_DIRis defined in wp-config.php and thewp-content/tempfolder exists with 755 permissionswp-content/uploads/is writable by the web server (folders 755, files 644)- The hosting panel shows free disk space — no maxed-out quota
- A test upload through Media, then Add New lands in the media library with no error
One more spot to check if it still fails: look at your .htaccess file for a php_value upload_tmp_dir line pointing at an old path. Comment it out and retest — a stale override there wins over the server default. And if the fix works but a plugin update later deletes or empties wp-content/temp, just re-create the folder; the WP_TEMP_DIR line in wp-config.php survives updates, so you will never have to re-edit the file.
Frequently asked questions
What does "Failed to write file to disk" mean in WordPress?
It means WordPress received your uploaded file but the server could not save it. Every upload is first written to PHP's temporary folder, then moved into wp-content/uploads. If that temp folder is missing or unwritable — or the disk is full — the write fails and WordPress shows this error.
Is this a WordPress problem or a hosting problem?
It is almost always a server configuration problem, not a WordPress bug: the PHP temp directory is missing or unwritable, folder permissions are wrong, or disk space is exhausted. That is why adding WP_TEMP_DIR to wp-config.php — which routes the temp write through a folder you control — fixes it for most people.
Why did the error start right after I moved to a new host?
Migrations commonly break the PHP upload_tmp_dir path — the old server's temp folder path was baked into the configuration, and it does not exist or is not writable on the new server. Creating wp-content/temp and defining WP_TEMP_DIR in wp-config.php replaces the broken path with one that works on the new host.
Can I fix it without editing wp-config.php?
Sometimes. If the cause is simply a full disk, deleting old backups fixes it with no file edits. If the cause is folder permissions, correcting them in File Manager is enough. But when the PHP temp directory itself is the problem, defining WP_TEMP_DIR in wp-config.php is the reliable fix — and it only takes one line.