Blog

Can’t Upload Theme – “Are you sure you want to do this” Error Fix

The “Can’t Upload Theme – Are You Sure You Want To Do This?” error appears quite regularly for WordPress users, however it should be fairly simple to solve. WordPress is written in PHP, which is a server-side scripting language that’s popular on the web. If you bought a theme and tried to upload the zip file using the WordPress uploader, you might run into the famous Can’t Upload Theme error. This error is very common, and your PHP setup is the probably the main reason behind it. To be more precise, The initial PHP configuration on most servers limits large file uploads – hence you are not allowed to upload your theme if it is larger than, let’s say, 2MB.

Fixing the Can’t Upload Theme – “Are you sure you want to do this” Error

The first solution is for people who have SSH access to their servers and are comfortable with using the terminal and vim. The second solution is for people that don’t want to play with server configuration files, and prefer an easier, GUI approach using an FTP client.

Option 1: Modify PHP Configuration (VPS/Dedicated Hosting)

Depending on the package you have, hosting providers allow you to change PHP’s configuration files. But this often applies to VPS and dedicated hosting plans that have SSH access. Shared hosting can be tricky to configure, as you’re on a server with tons of other people and you don’t have the desired control to make changes. That’s why this method is recommended for people with VPS or dedicated hosting plans.

The configuration file we need to modify is called php.ini.

Finding php.ini Location

Login in your server using SSH, and navigate to your document root. For this solution, we will be using an Ubuntu 14.04 LTS server. Provided you have installed all the necessary tools for your WordPress installation, open your document root by:

Command: cd /var/www/html

Once you are in the document root, carefully go through the following steps:

  1. Create an empty file called info.php by typing: sudo touch ./info.php.
  2. Open the newly created file by typing: sudo vim info.php. Once vim opens the empty file, we will write a single line of PHP code. Press I to enter the Insert Mode in vim, and then write: <?php php_info(); ?> . To save these changes, press Esc, then write :wq and press Enter. This will tell vim to write the changes and quit.
  3. Go to you domain or IP address, and open up this file by typing: www.mydomain.com/info.php
  4. Once it opens, look for Loaded Configuration File. It will be somewhere in the beginning of the listed configuration. This will tell us where the php.ini file is stored on our server. It should look something like: /etc/php5/apache2/php.ini. Make sure to copy or remember this path.

IMPORTANT: Once you know the path, you need to remove the info.php file, because other visitors can type the same URL that you entered and see your PHP configuration. It can make your website vulnerable to all types of attacks.

To remove the info.php, open your terminal again, make sure you’re still in the document root (if not, navigate back to it), and write:

Command: sudo rm ./info.php.

Modifying php.ini

Now that we know where our main configuration file lives, we will open it with vim, just like we opened info.php, and make some changes to it.

Steps:

  1. Open php.ini. Write the following command to open php.ini: sudo vim /etc/php5/apache2/php.ini. Remember, this is the path from info.php. It may be different in your case.
  2. The command above should open a pretty large file. Press I to enter insert mode of vim, and scroll until you find the following 2 variables (lines): post_max_size and upload_max_filesize. Their default values should be 8M and 2M. And this why your theme wouldn’t upload. Since you’re in insert mode, replace the default values to 30M on both variables.
  3. Common thing to do, is to increase the memory limit as well. Find the memory_limit variable, and increase it depending on how much RAM your server has. The default value of memory limit should be 128M. You can change that to 256M.
  4. Once you made these changes, press Esc to exit Insert mode, and write :wq to save the changes.
  5. Final step is to restart apache (our web server), so that these changes can take effect. Write the following command: sudo service apache2 restart. If you’re using a newer Ubuntu server (i.e. 16.04 LTS), the command is slightly different: sudo systemctl restart apache2.service.

You’ve made it! Now that we changed the upload file limit, you can upload your theme without any problems using the WordPress uploader.

Option 2: Upload Theme via FTP (Shared Hosting)

If you are on a shared hosting, or maybe you don’t want to mess around with server and PHP configuration, there is a simpler way to upload your theme. This solution involves creating an FTP account in your cPanel, and using an FTP client.

Login into your cPanel, and find the FTP Accounts section. There’s a good chance that your hosting provider already created a default FTP account for you. If so, you can use that one with your login password, or create a new one by inserting a path, username and a password.

The important thing here, is to get the FTP credentials that will allow you to login and upload the theme. There are 3 credentials that FTP clients ask for: server, username and password. You can get all these from the FTP Accounts section in your cPanel.

Now that you have an FTP account, it’s time to put it into use. There are many FTP clients around, both paid and free. If you’re on a Mac, I would suggest Cyberduck, a free FTP solution with great user interface. If you’re on Windows, check out FileZilla.

Regardless of which client you pick, once you install it and open it, find the Open/New Connection tab. Once you click on Open Connection, populate the following files accordingly:
Protocol: Choose File Transfer Protocol (FTP)
Port: This should be pre-populated for you, but in case it isn’t, the File Transfer Protocol uses Port 21 for incoming connections.
Server: This is the server field from your FTP Accounts. Often, hosting providers set the server name as the domain name – without the “www”. So, it could look something like mydomain.com.
Username: The FTP username
Password: The FTP password

Once you hit connect, you should see your root directory (which was /var/www/html in our case – as seen in the first solution). From there, you can click between directories just as you would do in your OS. This is much easier from navigating between files and directories using the terminal like we did above.

Unpack your zip theme file in your computer, and navigate to /wp-content/themes/ in the FTIP client on the server. Now simply drag and drop the unzipped folder into the theme’s directory, and wait a few minutes for the transfer to complete. Note that the theme is larger, the transfer could take up to 1 hour to complete. Your internet connection speed is also important.

As soon as the transfer finishes successfully, you can go to WordPress Dashboard -> Appearance, and find your theme there. Then, simply activate the theme and you should have everything fully working.

Note: Make sure that the transfer was completed successfully and error-free. FTP can be a fragile process, and clients can stop the connection or transfer to the server if something’s wrong. You can make sure that everything went fine by checking out the client’s transfer console.

If you keep getting interrupted, you would need to remove the files that are already transferred on the server, and start over – until the theme is 100% uploaded to the server.



Scroll to top