WordPress: Fix the error “Download Failed. Destination directory for file streaming does not exist or is not writable.”

Image showing WordPress error:

I recently changed the domain of this website from codesnippets.astralmemories.com to codesnippets.freewebtools.net, and when I wanted to update one of the plugins, I received the following error:

Download failed. Destination directory for file streaming does not exist or is not writable.

This is usually caused by incorrect permissions in the wp-content folder.

One good solution is to create a temporary folder outside of the install directory, in order words, find the root folder of your WordPress installation and go up a directory. Now create a folder called ‘temp’ with 777 permissions.

From the terminal:

mkdir temp
chmod 777 temp

Edit the wp-config.php file found in the root directory of your WordPress installation folder and add the following line of code at the bottom.

define('WP_TEMP_DIR', ABSPATH . '/../temp/');

Now you should be able to update and install new plugins without issues.