I need to create a directory in public:// when the module is installed via file_prepare_directory(). I used this code in function mymodule_install():

$mydir = 'public://mydir';  
file_prepare_directory($mydir, FILE_CREATE_DIRECTORY);` 

Upon uninstalling, clear the cache, and installing the module it does not create mydir.


Are you sure the directory where you are creating directory is writable?

file_prepare_directory checks that the directory exists and is writable. You can try drupal_mkdir statement to create directory in hook_install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.