CodeIgniter Forums
Resize after upload - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Resize after upload (/thread-68747.html)



Resize after upload - scalla - 08-19-2017

Good day, am trying to resize on upload, seems not to be working out. it shows this error "imagecopyresampled(): supplied resource is not a valid Image resource" after resizing to just one folder.
PHP Code:
if ($imagefile $this->request->getFile('avatar'))
         
  {
         
      if ($imagefile->isValid() && ! $imagefile->hasMoved())
                {
                    
$path FCPATH.'profile/';
     
            $filename $imagefile->getRandomName();
     
            $file_full_path $path $filename;
                 
  if($imagefile->move($path$filename))
                 
  {
                     
  $sizes = array('600','920','200');
             
           foreach ($sizes as $size)
                        {
                         
  $resizepath $imagefile->setPath($path.$size.'/');
                            \
Config\Services::image('gd')
                         
       ->withFile($file_full_path)
                         
           ->resize($size230,true'height')
                         
       ->save($resizepath.$filename);
                        }
                        
$result['status'] = 200;
     
                $result['image'] = $path.'200/'.$filename;
                    }

                }
            }