codeigniter调整大小图像导致500错误

时间:2017-12-08 11:55:14

标签: codeigniter codeigniter-upload

此代码将捕获异常并将上传图像,但是当我在do_upload函数中添加resize组件时,如果我尝试上传应该工作的图像,则会出现500错误

<?php

class Upload extends CI_Controller {

  function __construct()
{
    parent::__construct();
    $this->load->helper(array('form', 'url'));
    //form_upload('userfile'); 
}

function index()
{
    $this->load->view('upload_form', array('error' => ' ' ));
}

function do_upload()
{
 if($this->upload->do_upload('userfile'))
{
$fInfo = $this->upload->data(); // get all info of uploaded file
//for image resize
$img_array = array();
$img_array['image_library'] = 'gd2';
$img_array['maintain_ratio'] = TRUE;
$img_array['create_thumb'] = TRUE;
//you need this setting to tell the image lib which image to process
$img_array['source_image'] = $fInfo['full_path'];
$img_array['width'] = 113;
$img_array['height'] = 75;

$this->image_lib->clear(); // added this line
$this->image_lib->initialize($img_array); // added this line
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
 }
 else
 {
  $error = array('error' => $this->upload->display_errors());

                    $this->load->view('upload_form', $error);

  }
}}

0 个答案:

没有答案