Drupal: rogrammatically change file system path
Is there a way to change the files directory path, using a function from the drupal api?
Thanks in ad开发者_如何学Cvance,
—Albe
EDIT: Failed initial reading comprehension. Answer:
variable_set('file_directory_path', 'path/to/files');
Drupal uses conf_path() . '/files'
as the default fallback value.
Answers to Related Questions
To change the location of the files directory itself, check out the File System configuration page at admin/settings/file-system. You can change the path of the files directory to any Drupal-writable path on your server.
If you mean, how do you change the path to which files are saved within the files directory, that depends on what you are using to do file uploads.
- Upload module: The Uploadpath module mentioned by @vilepickle looks good.
- Filefield module: It already allows the path to be configured by global and user tokens in a similar way to uploadpath, and configurable by the node information where you upload the file by Filefield Paths.
- If you are using IMCE or one of the assortment of graphical file managing modules, this is answered on a per module basis.
Not sure about this exactly, but the module http://drupal.org/project/uploadpath lets you specify a different upload directory per node type.
精彩评论