WordPress: Uploads folder does not exist

October 11, 2018 Coding, Tips, Wordpress

There are some cases in which the wp-content/uploads folder is missing from your WordPress installation.
That depends on the host which you relied on for the wp installation.

If this is your case you’ve got two options:

  1. Create it manually.
  2. Add it by code

Manually

Creating manually could be done with an FTP service like Filezilla. Just move into the wp-content folder and create a new folder named uploads.

Make sure to give it 0777 permissions (read, write and execute to all the users).

By code

To create a folder by code you should:

  1. Check if the folder already exist.
  2. Create the folder if it does not.

This is the code:

$folder = get_home_path() . 'wp-content/uploads/';

if (!file_exists($folder)) {
    mkdir($folder, 0777, true);
}

Now you should place the code in your theme functions.php file.
If your theme is a downloaded one (you did not code it) we suggest you create a child instead of modifying it.

That’s all you need to do to be sure that the folder does exist.

Leave us a feedback 😀