title: How to set 755 permissions in php after creating folder in the existing folder
body: <p>I have a following code in the Codeigniter controller to upload some files to "upload" folder in the remote ubuntu server. In this case there is created a new folder named as officer_id in the upload folder when upload files and should be applied 755 permissions to it. Otherwise rejected to upload the files.</p>
  
  <pre><code> public function addFiles()
          {
  
              $this-&gt;checkPermissions('add', 'officer');
              $bc = array(array('link' =&gt; '#', 'page' =&gt; 'Attachments'));
              $meta = array('page_title' =&gt; 'Officers - Files', 'bc' =&gt; $bc);
              $this-&gt;data['officer'] = $this-&gt;Officer_model-&gt;getOfficer();
  
  
              $this-&gt;form_validation-&gt;set_rules('officer', "Officer", 'required');
  
              if ($this-&gt;form_validation-&gt;run() == true) {
                  $files = $this-&gt;multi_upload($_FILES['file'], './uploads/' . $this-&gt;input-&gt;post('officer'));
                  if (!empty($files)) {
                      foreach ($files as $fname) {
                          $fdata[] = array(
                              'officer' =&gt; $this-&gt;input-&gt;post('officer'),
                              'file_name' =&gt; $fname,
                              'status' =&gt; 1,
                          );
                      }
                      if ($this-&gt;db-&gt;insert_batch('tbl_officer_files', $fdata)) {
                          $this-&gt;session-&gt;set_flashdata('message', 'Officer Attachments Updated Successfully ..!!');
                          redirect('officer/addFiles');
                      } else {
                          $this-&gt;session-&gt;set_flashdata('message', 'Officer Attachments Updation Failed ..!!');
                          redirect('officer/addFiles');
                      }
  
                  }
              }
              $this-&gt;render('officer/addFiles', $meta, $this-&gt;data);
  
          }
  
          public function saveUpload()
          {
              $this-&gt;multi_upload($_FILES['file']);
              if ($this-&gt;upload-&gt;do_upload('file')) {
                  $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
  
                  $inputFileName = './uploads/' . $data['upload_data']['file_name'];
  
                  echo json_encode(array('success' =&gt; 'Files have been uploaded successfuly ..!!'));
              } else {
                  $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
                  echo json_encode($error);//array('error' =&gt; 'You are not allowed to upload such a file.',
  
              }
          }
  </code></pre>
  
  <p>How can I modified my code to enable this (Like chmod ......) ? Can anyone help ?  </p>