1

When creating directory using function drupal_mkdir in custom module, how to set folder permission access to "Create and delete files"?

drupal_mkdir('public://myfolder/');

1 Answer 1

3

The second parameter is $mode, which you can provide. e.g.

drupal_mkdir('public://myfolder/', 0755);

By default the 'file_chmod_directory; will be used, which, by default, is 0775.

Exactly what mode you use will obviously depend on your server set up. If you're not sure, ask your sysadmin what it should be.

3
  • I have an error: "Warning: mkdir(): Permission denied in DrupalLocalStreamWrapper->mkdir() (line 639 of /var/www/videogallery/includes/stream_wrappers.inc)."
    – josaric
    Oct 21, 2014 at 9:43
  • You need to change the permissions on the parent folders, so your web server user can write to the files folder. You'll need to do this on the server itself, Drupal can't do it.
    – Clive
    Oct 21, 2014 at 10:04
  • okay setting the correct permission for default fixed issue for me. sudo chmod -R 775 default/ Aug 29, 2022 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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