如何删除文件,在代码的输出下面..但是此代码无法从目录中删除文件....
控制器中的
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);
}
输出
遇到PHP错误
严重性:注意
消息:尝试获取非对象的属性
文件名:controllers / C2C_contr.php
行号:264
遇到PHP错误
严重性:注意
消息:尝试获取非对象的属性
文件名:controllers / C2C_contr.php
行号:267
遇到PHP错误
严重性:警告
消息:取消链接(upload_attachments /):权限被拒绝
文件名:controllers / C2C_contr.php
行号:267
Array ( [0] => stdClass Object ( [id] => 111 [attched_files] => Untitled4.png [attched_remarks] => ) )
答案 0 :(得分:1)
您应该更新以下行 -
的unlink(&#39; upload_attachments /&#39; $ del_image-&GT; attched_files);
//使用此
进行更新的unlink(&#39; upload_attachments /&#39; $ del_image [0] [&#39; attched_files&#39;]);