The Uploaded File Could Not Be Moved

Posted by: Mark Lawrence

The Uploaded File Could Not Be Moved

Recently while trying to upload a new theme to Wordpress I encountered an error that prevented Wordpress from copying the theme file. This article explains the solution that I have been able to replicate in three distinct Wordpress installations. Each Wordpress site was encountering the same problem when attempting to upload a large theme file, and the solution worked successfully on each platform.

This may unfortunately not solve all 'unable to move...' errors but it may assist some people. I'll quickly touch on why the error comes up and what can be done to rectify it.

The Uploaded File Could Not Be Moved...!

When you upload a theme to Wordpress using the in-built theme manager to upload zip files, the file is read from your computer, or another server, and then is attempted to be copied to your Wordpress installation.

Most web hosts as part of their security setup do not allow forms to upload large files as there are alternate means of upload, such as FTP. If the file upload limit is not overridden by a script then chances are you wont be able to upload a file that the server recognises as being too large.

Within the PHP configuration file that resides on your server there are settings that control the limits of files that can be uploaded. The two settings we are looking for are upload_max_filesize and post_max_size. These settings can inhibit the ability to upload large files via forms. In the case of Wordpress, the theme is bundled into a zip file which may in some cases be larger than the PHP upload_max_filesize limit or the post_max_size limit.

How Do I Know When Big is Too Big

There are a couple of ways that you can check the upload_max_filesize and post_max_size values for your server. If you have access to cPanel then you can follow these steps, but please note that not all cPanel installations may have this feature.

  • Log into your cPanel
  • Scroll to the bottom of the page and click on PHP Configuration
  • At the very bottom of the PHP Configuration output you should see File Uploads upload_max_filesize Maximum allowed size for uploaded files.

This is the limit as specified by your webhost. You can also view the file size limit in WHM.

  • Log into WHM
  • Click on Service Configuration in the side menu
  • Click on PHP Configuration Editor
  • Change the mode from Basic to Advanced
  • Scroll down, or search within your browser which is generally Control-F, for upload_max_filesize and then post_max_size

If you cannot access either cPanel or WHM but have access to your server via FTP you can upload a PHP info script which will output the contents of the PHP configuration file to your browser.

To do this, follow these steps.

  • Create a new file in a text editor such as Notepad
  • Copy the following code exactly as it appears into the new text file
<?php
print phpinfo();
?>
  • Save this file and call it phpinfo.php
  • Upload the file via your FTP program to the public directory of your website. This will generally be public_html
  • Open a browser and enter your domain name, followed by a trailing slash, followed by the file phpinfo.php. For example: www.mywebsite.com/phpinfo.php
  • Scroll down, or search within your browser for upload_max_filesize and post_max_size
  • NOTE: Delete the phpinfo.php file once you have made a note of the values. Do not leave this file on your server

So now that we have the maximum file sizes, we need to be able to change these values to something larger in order for Wordpress to be able to upload larger theme zip files.

NOTE: These changes that you make may alter the way your system operates. Please do not make these changes unless you feel comfortable doing so.

Changing PHP Upload Limit in WHM

If you have access to the PHP Configuration Editor in WHM then this is very simple to do.

  • Log into WHM
  • Click on Service Configuration Editor
  • Click on PHP Configuration Editor
  • Switch the mode from Basic to Advanced
  • Locate the value assigned to upload_max_filesize and change it to something larger such as 10M. Ensure that you enter a number followed by ‘M’.
  • Locate the value assigned to post_max_size and change it to something larger such as 10M. Ensure that you enter a number followed by ‘M’.
  • Save the PHP configuration to apply your changes
  • Switch back to your Wordpress administration panel and try to upload the Wordpress theme again

If you do not have access to WHM or any other host management software that will permit you to change the values of your PHP configuration file, you can try the steps below.

Manually Overriding the PHP Upload Limit via FTP and Htaccess

To manually override the limit imposed by the PHP configuration file you first need to check if a specific file exists on your server called .htaccess. Note the period(.) at the start of the filename. This is important and must remain intact.

To check if the file exists you will need to log into your server via FTP, or you can use the file manager that comes with your cPanel installation. Once you have logged in follow these steps.

  • Check that you are viewing the contents of the public_html folder
  • Within this folder check to see if there is a file called .htaccess

If you cannot locate a file named .htaccess in your public_html folder, you can create your own .htaccess file and upload it to the server. One issue that you may face when creating your own .htaccess file is that Windows will try to add a file extension to it such as .txt.

If this happens don't panic, simply upload the file to the server and change its name using your FTP progam back to .htaccess once it has uploaded.

  • Right click on the file called .htaccess and from the menu select ‘Edit’. Most FTP programs will permit you to edit a file simply by right-clicking the file and presenting an ‘Edit’ option
  • Once you have selected ‘Edit’ the file will be downloaded to a temporary location and opened in a default editor. In many cases this will generally be Notepad
  • In the opened file add the following two lines after any existing text
  • php_value upload_max_filesize 10M
    php_value post_max_size 10M
     

    Save the file, which should automatically be uploaded back to the server. Again, switch back to your Wordpress administration panel and attempt to upload the theme again.

    What if none of this works for me

    If you are unable to do the make the changes states above, or are concerned about making changes to your system you can contact the support department at your web-host and advise them that you are trying to upload themes into Wordpress, and require the upload limits to be increased.