WordPress Media Upload Error – No Temp Directory

You can configure WordPress and tell it which path it should use for its temporary directory, for instance to upload media files. In many cases you never need to worry about this, however if your site is hosted, you have little control over the file structure and permissions, plus you run into a problem as shown below, you may need to configure your own temp path.

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/tmp//copyvob.tmp) is not within the allowed path(s): (VIRTUAL_DOCUMENT_ROOT) in /www/zzl.org/k/o/e/koenaerts/htdocs/wp-includes/functions.php on line 2340
Warning: touch() [function.touch]: SAFE MODE Restriction in effect. The script whose uid is 499712 is not allowed to access /tmp owned by uid 0 in /www/zzl.org/k/o/e/koenaerts/htdocs/wp-admin/includes/file.php on line 177

In this case, WordPress uses the /tmp path as its temporary directory, however has no write permissions to it. Instead we are going to create a new directory temp under the /wp-content folder. This can be done with an FTP client such as FileZilla. Once “temp” has been created, its permissions need to be set to 777, which is equivalent to drwxrwxrwx in UNIX/Linux.

After you have created the new temp folder, you append the following lines to wp-config.php:

/** Define tmp dir because /tmp does not work. */
define('WP_TEMP_DIR', ABSPATH.'wp-content/temp/');

Leave a Reply

Your email address will not be published. Required fields are marked *

*