如何删除图像文件?

时间:2014-05-04 07:08:18

标签: codeigniter text

如何从删除按钮中的codeigniter中删除上传文件夹中的图像文件? 任何人都可以指导我吗??? 这是我的上传图像文件的控制器

private function upload() {
    $config['upload_path'] = 'assets/uploads/orginal/';
    $config['allowed_types'] = 'gif|jpg|png|jpeg|x-png';
    $config['max_size'] = '500';
    $config['max_width'] = '1600';
    $config['max_height'] = '1200';
    $config['remove_spaces'] = TRUE;
    $this->load->library('upload', $config);
    if ($this->upload->do_upload()) {
        $img = $this->upload->data();
        // create thumbnail
        $new_image = 'assets/uploads/thumbs/' . $img['file_name'];

        $c_img_lib = array(
            'image_library' => 'gd2',
            'source_image' => $img['full_path'],
            'maintain_ratio' => TRUE,
            'width' => 100,
            'height' => 100,
            'new_image' => $new_image
        );

        $this->load->library('image_lib', $c_img_lib);
        $this->image_lib->resize();
    } else {
        $this->data['error'] = $this->upload->display_errors();
    }
}

1 个答案:

答案 0 :(得分:0)

使用unlink()函数:

unlink($new_image);

http://pt1.php.net/manual/en/function.unlink.php