The files directory created in the initial install is the default file system path used to store all uploaded files, as well as some temporary files created by Drupal. After installation, the settings for the file system path may be modified to store uploaded files in a different location.

You should be explicit about the notation for identifying the temporary directory relative to the Drupal instance on the server, (which is usually also the server's web root directory). If they are both contained within the same parent directory then use the notation:
../[temporary directory]

The directory structure that supports this notation might look like this:

/parent_dir
  /tmp
  /public_html (www)
    (DRUPAL ROOT directory files)
    sites
      default
      ...
    ...

It is not necessary to modify this path, but you may wish to change it if:

  • your site runs multiple Drupal installations from a single codebase (modify the file system path of each installation to a different directory so that uploads do not overlap between installations); or,
  • your site runs a number of web server front-ends behind a load balancer or reverse proxy (modify the file system path on each server to point to a shared file repository).

To modify the file system path:

  1. Ensure that the new location for the path exists or create it if necessary. To create a new directory named uploads, for example, use the following command from a shell or system prompt (while in the installation directory):
    mkdir uploads
  2. Ensure that the new location for the path is writable by the web server process. To grant write permissions for a directory named uploads, you may need to use the following command from a shell or system prompt (while in the installation directory):
    chmod o+w uploads
  3. Access the file system path settings in Drupal by selecting these menu items from the Navigation menu:Administer > Site configuration > File system
  4. Enter the path to the new location (e.g.: uploads) at the File System Path prompt.

Note
Changing the file system path after files have been uploaded may cause unexpected problems on an existing site. If you modify the file system path on an existing site, remember to copy all files from the original location to the new location.

Some administrators suggest making the documentation files, especially CHANGELOG.txt, non-readable so that the exact version of Drupal you are running is slightly more difficult to determine. This has been discussed publicly many times during Drupal's history. Please see the FAQ: Why doesn't Drupal hide CHANGELOG.txt? for more information.

Comments

wsafley’s picture

There's one more gotcha if you have already uploaded files - Drupal stores the path to the file in the Files table, so if you change the settings under "File System" and remove the old directory - whoops, there go your files because it's looking at the old path!

If you have existing files, you need to go back and do a database blast to fix the path in the files table as well. I find it easy if you have phpmyadmin, or something similar, to do an export of the files table using SQL UPDATE statements, save the file, open it in a text editor and do a search and replace, then copy and paste the update statements back into the SQL window of phpmyadmin.

marktheshark’s picture

Is there any module that can move files (e.g. for filefields) automatically upon changing the file system path?

tronathan’s picture

Subscribing, also see http://drupal.org/node/84895#comment-4450532 (relevant)

tronathan’s picture

cheche’s picture