سؤال

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.

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

Please use the proper APIs.

$directory = file_default_scheme() . '://yourdir';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top