PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, May 16, 2022

[FIXED] How to create a folder in site->default->files with write read permissions with Drupal?

 May 16, 2022     drupal, drupal-7, php     No comments   

Issue

I'm working on Ubuntu and I need to create a folder in Drupal's default->files folder with write permission so that I would be able to add files to that folder later on.

Here is the code I have:

drupal_mkdir('public://' . $new_dir . '/');
$file = file_copy($file, 'public://' . $new_dir . '/' . $file_name);

Solution

    drupal_mkdir('public://' . $new_dir , 0777);

if you need it to be recursive set third argument to true.

update:

    $oldumask = umask(0);
    drupal_mkdir("public://". $new_dir , 0777);
    umask($oldumask);


Answered By - bhab
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing