CodeIgniter Forums

Full Version: Resize after upload
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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;
                    }

                }
            }