允许的字节大小耗尽 - Codeigniter

时间:2014-12-06 00:27:51

标签: php codeigniter

当您调用库上传控制器时,出现错误

  

致命错误:允许的内存大小为1073741824字节(已尝试   分配65488字节)   第478行的D:\ XAMPP \ htdocs \ Symfony \ web \ system \ core \ Log.php

控制器方法编辑:

 function edit($id){
  $this->action ="edit";
  if (empty($_POST["id"])) $_POST["id"]  = $id;
  if(isset($_POST['edit'])){
   $_POST['image'] = $this->model_img_upload->imageUpload($this->imUploadConfig);
   if($this->model_akcii->edit_data($_POST)){
    $this->session->set_flashdata('msg',$this->lang->line('msg_edit'));
    redirect('akcii');
   }
  }
  $this->item = $this->model_akcii->get_info($id);
  $this->item_lang = $this->model_akcii->get_lang_info($id);
  $this->load->view("edit",$this);
 }

imageUpload方法:

function imageUpload ($config=array()){
  if(isset($_FILES['userfile'])){
  $_FILES['userfile']['name'] = $this->transliterate($_FILES['userfile']['name']);
   $config['upload_path'] = isset($config['upload_path'])?$config['upload_path']:$_SERVER['DOCUMENT_ROOT'].'/userfiles/images/' ;
   if (!file_exists($config['upload_path']))
    if (phpversion() >= 5) mkdir($config['upload_path'],0755,true); else {
     $paths = split("/",$config['upload_path']); $makepath="";
     foreach ($paths as $p){ $makepath .=$p."/"; if (!file_exists($makepath)) mkdir($makepath,0755); }
    }
   $config['allowed_types'] = isset($config['allowed_types'])?$config['allowed_types']:'jpg|gif|png' ;
   $config['max_size'] = isset($config['max_size'])?$config['max_size']:'1000' ;
   $config['max_width'] = isset($config['max_width'])?$config['max_width']:'2048' ;
   $config['max_height'] = isset($config['max_height'])?$config['max_height']:'2048' ;
   $this->load->library('upload', $config);
   if ( ! $this->upload->do_upload()) {
    $error = array('error' => $this->upload->display_errors());
    return false;
   } else  {
    $imgdata = $this->upload->data();
    $config['image_library'] = 'GD2' ;
    $config['source_image'] = $imgdata['full_path'];
    $config['quality'] = isset($config['quality'])?$config['quality']:"100%" ;
    $config['create_thumb'] = isset($config['create_thumb'])?$config['create_thumb']:TRUE ;
    $config['maintain_ratio'] = isset($config['maintain_ratio'])?$config['maintain_ratio']:TRUE ;
    $config['width'] = isset($config['width'])?$config['width']:140 ;
    $config['height'] = isset($config['height'])?$config['height']:115 ;
    $this->load->library('image_lib', $config);
    $this->image_lib->resize();
    return $imgdata['file_name'];
   }
  }

升级引擎到codeigniter 3后出现此错误。

memory_limit = 1G

0 个答案:

没有答案