title: How to set a permission after creating a directory using PHP?
body: <p>I have a problem with my code. In my code there is a part that can generate a directory in the server and when I checked the directory in the FTP the initial folder is generated but the subfolders are not and when I try to open the main folder there is a log that says:</p>
  
  <pre><code>Response:   550 /httpdocs/ecommerce/image/catalog/sellers/826: Permission denied
  Error:  Failed to retrieve directory listing
  </code></pre>
  
  <p>When I checked the newly created main folder it contains this permission:</p>
  
  <pre><code>e(01411)
  </code></pre>
  
  <p>In my code I have this:</p>
  
  <pre><code>public function addUser($data) {
  
      $this-&gt;db-&gt;query("INSERT INTO `" . DB_PREFIX . "user` SET username = '" . $this-&gt;db-&gt;escape($data['username']) . "', shop_name = '" . $this-&gt;db-&gt;escape($data['shop_name']) . "', user_group_id = '" . (int)$data['user_group_id'] . "', salt = '" . $this-&gt;db-&gt;escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "', password = '" . $this-&gt;db-&gt;escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', firstname = '" . $this-&gt;db-&gt;escape($data['firstname']) . "', lastname = '" . $this-&gt;db-&gt;escape($data['lastname']) . "', email = '" . $this-&gt;db-&gt;escape($data['email']) . "', image = '" . $this-&gt;db-&gt;escape($data['image']) . "', status = '" . (int)$data['status'] . "', date_added = NOW()");
      $get_customer_id = $this-&gt;db-&gt;getLastId();
  
      $directory = DIR_IMAGE . 'catalog/sellers/' . $get_customer_id;
  
      if(!file_exists($directory)) {
  
          mkdir($directory, 777);
  
          mkdir($directory . '/profile', 777);
          mkdir($directory . '/banner', 777);
          mkdir($directory . '/products', 777);
  
      }
  
  }
  </code></pre>
  
  <p>In my localhost it is working properly but when I upload it has an error.
  Can you help me with this?</p>