开发者

How do I create a directory from hook_install of a module in Drupal 7?

开发者 https://www.devze.com 2023-02-03 20:21 出处:网络
Actually, I know how to create a directory = mkdir. However, I need to pass it a full absolute path in the server, and I don\'t know how to get the relevant path in hook_install.

Actually, I know how to create a directory = mkdir.

However, I need to pass it a full absolute path in the server, and I don't know how to get the relevant path in hook_install.

I tried using开发者_运维问答 base_path(), but it returned '/'.

The path I want is sites/default/files (inside "files" I create the directory).

Thanks.


Please use the proper APIs.

$directory = file_default_scheme() . '://yourdir';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);


Did you try mkdir('sites/default/files/yourdir')? If so, where does that create the directory? If not, why not?

Relative directory names are resolved based on the working directory. The working directory in Drupal is usually the directory in which your install.php and index.php is located.

0

精彩评论

暂无评论...
验证码 换一张
取 消