第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

codeigniter 從文件夾中刪除文件

codeigniter 從文件夾中刪除文件

PHP
蕭十郎 2022-07-29 16:38:03
請誰能幫我我想從文件夾codeigniter中刪除文件這是我的控制器 public function delete($id = false) {        if (!$id)            show_404();        $this->{$this->model}->{$this->_primary_key} = $id;        $data['item'] = $this->{$this->model}->get();        if (!$data['item'])            show_404();        $this->{$this->model}->delete();        redirect('admin/' . $this->module);    }    public function image($var, $id) {        $config['upload_path'] = './cdn/sliders/';        $config['allowed_types'] = 'gif|jpg|png|jpeg';        $this->load->library('upload', $config);        if ($this->upload->do_upload('image')) {            $data = $this->upload->data();            if ($data['file_name'])                $this->{$this->model}->image = $data['file_name'];        }        return true;    }
查看完整描述

3 回答

?
喵喔喔

TA貢獻1735條經(jīng)驗 獲得超5個贊

就像是


public function delete_video($id)

{

    $this->db->where('id', $id);

    $this->db->select('video');

    $video_name = $this->db->get('vs_videos')->row_array();

    if ($video_name) {

        @unlink('./vs_asset/videos/' . $video_name['video']);


        $this->db->where('id', $id)

            ->delete('vs_videos');

        $result = $this->db->affected_rows();

        return $result;

    } else {

        return;

    }

}


查看完整回答
反對 回復(fù) 2022-07-29
?
慕尼黑的夜晚無繁華

TA貢獻1864條經(jīng)驗 獲得超6個贊

$filename = file_name_with_full_path

您可以使用 unlink($filename) 函數(shù)在 php 中刪除文件

請查看以下鏈接了解詳情

https://www.w3schools.com/php/func_filesystem_unlink.asp


查看完整回答
反對 回復(fù) 2022-07-29
?
慕斯709654

TA貢獻1840條經(jīng)驗 獲得超5個贊

非常感謝,我得到了答案


這里是如何工作的。


public function delete($id = null) {


        if (!$id)

            show_404();

        $this->{$this->model}->{$this->_primary_key} = $id;

        $path = './cdn/projects/';

        $data['item'] = $this->{$this->model}->get();

            if (!$data['item'])

                show_404();

        @unlink($path.$data['item']->image);

        $this->{$this->model}->delete();

        redirect('admin/' . $this->module);

    }


查看完整回答
反對 回復(fù) 2022-07-29
  • 3 回答
  • 0 關(guān)注
  • 175 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號