When you call the controller upload anywhere, it hangs and gives an error

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 65488 bytes) in D: \ XAMPP \ htdocs \ Symfony \ web \ system \ core \ Log.php on line 478

The edit method in my controller:

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 method:

 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']; } } 

On the version of codeigniter 1.x, everything worked, updated to the 3rd version, and started issuing this error. In the documentation - no changes in this controller. Help me to understand

  • one
    PS Why do you need the third CI? if he is only in the process, you are in vain. - Manitikyl
  • Full stack and source CI in the studio. There is no such line in the develop branch on githaba. - etki
  • Because I wanted a third one. I do not release in production, it is so, for myself. - MAKADORE
  • What line is not exactly? - MAKADORE
  • @ Alexander Klyuev, 478, what else - etki

1 answer 1

1 Way:

In php.ini - memory_limit = 128M; (replace with another number or -1)

2 Way:

In the beginning of your script ini_set ('memory_limit', 'x'); (where X is your number)

  • And do not forget to buy a more powerful server, oh yeah - etki
  • The clever man is not the problem of RAM, but in the script - MAKADORE
  • @Alexander Klyuev, the problem is not in the script, but in the php settings. About the server you were told, most likely, because 1073741824/1024/1024/1024 = 1GB. What are you trying to download? If the memory is not so much, then you were given a good advice - the memory is not superfluous. - BOPOH