Unlink permission denied on codeigniter

↘锁芯ラ 提交于 2019-12-11 05:48:46

问题


How do I delete a file, Below the output of the code.. but this code is not working to del the file from the directory....

in controller

public function delete_by_id()
{
        $id = $this->uri->segment(3);
        $schemeid = $this->uri->segment(4);
        $link = $this->uri->segment(5);

        $tablename = $this->uri->segment(6);
     //unlink code ------------------------------------------>
      $del_image = $this->C_model->getrecordwhere($tablename, array('id' => $id));

      unlink('upload_attachments/'.$del_image->attched_files);


       echo '<pre>';print_r($del_image);die;
   // if($tablename== 'progress')
  //  {

        $where = array('id'=>$id);
        //$where = array('id'=>$id);
        //$where = array('id'=>$id);
        //$where = array('id'=>$id);
        $this->C_model->deleteid($tablename,$where);

        redirect('C2C_contr/'.$link.'/'.$schemeid);

}

output

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: controllers/C2C_contr.php

Line Number: 264

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: controllers/C2C_contr.php

Line Number: 267

A PHP Error was encountered

Severity: Warning

Message: unlink(upload_attachments/): Permission denied

Filename: controllers/C2C_contr.php

Line Number: 267

Array
(
    [0] => stdClass Object
        (
            [id] => 111
            [attched_files] => Untitled4.png
            [attched_remarks] => 
        )
)

回答1:


You should update below line -

unlink('upload_attachments/'.$del_image->attched_files);

//update with this

unlink('upload_attachments/'.$del_image[0]['attched_files']);



来源:https://stackoverflow.com/questions/26622735/unlink-permission-denied-on-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!