Hardcoding the Temporary Directory Path

When working on a local copy of a site that also has a production, stage, and/or development environment on another server, it can be handy to hard-code the "Temporary directory" file path as found on admin/config/media/file-system

The reason is so that when you restore a copy of the database from another server to your local machine, you don't have to redo the temporary directory setting. For example, on most sites we build, we set up a shared development environment on WebEnabled (shameless plug) where multiple developers are often configuring different parts of the site. When I want to work locally, I like to have an up-to-date copy of the database. I use the Backup and Migrate module or Drush to copy the database from the shared development environment to my local machine.

To hard-code the temporary directory path of your local site in Drupal 7 and earlier, simply add the following line to the bottom of your local settings.php file:

$conf['file_temporary_path'] = '/tmp';

Where "/tmp" is the your local temporary directory path.

Update: for Drupal 8, use this line, also in your settings.php file:

$config['system.file']['path']['temporary'] = '/tmp';