在CI中上传.tif文件时出现问题

时间:2017-10-03 17:49:05

标签: php codeigniter

上传.tif文件

时出现以下问题
  

您的服务器不支持处理此类图像所需的GD功能。

我已经在Stack Overflow上检查过this post但仍存在同样的问题。任何人都可以帮我解决这个问题吗?

请检查我写的代码,以便在不同文件夹中上传带或不带水印的图片:

if (!is_dir('assets/ori_img/')) {
    mkdir('assets/ori_img/', 0777, true);
}
if (!is_dir('assets/watermark_img/')) {
    mkdir('assets/watermark_img/', 0777, true);
}
$config1['upload_path']   = 'assets/ori_img/'; 
$config1['allowed_types'] = 'jpeg|png|jpg|svg|gif|tif|tiff';
$this->load->library('upload', $config1);
$this->upload->initialize($config1);
if ( ! $this->upload->do_upload('image')) {
    $error = array('error' => $this->upload->display_errors());
    $this->session->set_flashdata('error', $error['error']);
    redirect('photographer/uploadimage');
}
$config['upload_path']   = 'assets/watermark_img/'; 
$config['allowed_types'] = 'jpeg|png|jpg|svg|gif|tif|tiff';
$this->load->library('upload', $config);
$this->upload->initialize($config);

$config['image_library'] = 'GD2';
$_FILES['file']['name'] = $_FILES['image']['name'];
$_FILES['file']['type'] = $_FILES['image']['type'];
$_FILES['file']['tmp_name'] = $_FILES['image']['tmp_name'];
$_FILES['file']['error'] = $_FILES['image']['error'];
$_FILES['file']['size'] = $_FILES['image']['size'];
$config['source_image'] = $_FILES['image']['tmp_name'];
list($width, $height) = getimagesize($_FILES['file']['tmp_name']);

$config['wm_type'] = 'overlay';
$config['wm_overlay_path'] = 'assets/img/overlay_watermark.png';
$config['wm_opacity'] = '100';
$this->load->library('image_lib', $config);

// DEFINE YOUR WATERMARK LOCATIONS
$watermark_array = array(
    array('horizontal' => 'center', 'vertical' => 'middle'),
    array('horizontal' => 'left', 'vertical' => 'top'),
    array('horizontal' => 'right', 'vertical' => 'top'),
    array('horizontal' => 'left', 'vertical' => 'bottom'),
    array('horizontal' => 'right', 'vertical' => 'bottom')
);

// ADD YOUR WATERMARKS
foreach ($watermark_array as $row) {
    $config['wm_vrt_alignment'] = $row['vertical'];
    $config['wm_hor_alignment'] = $row['horizontal'];

    $this->image_lib->initialize($config);
    // $this->image_lib->watermark();
    if ( ! $this->image_lib->watermark()) { 
        echo $this->image_lib->display_errors();
    }
    $this->image_lib->clear();
}

if ( ! $this->upload->do_upload('image')) {
    $error = array('error' => $this->upload->display_errors());
    $this->session->set_flashdata('error', $error['error']);
    redirect('pgrapher/uploadimage');
}

0 个答案:

没有答案