CodeIgniter Forums
Ci4 Pass Uploaded Image from Controller to Model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Ci4 Pass Uploaded Image from Controller to Model (/showthread.php?tid=76451)



Ci4 Pass Uploaded Image from Controller to Model - 68thorby68 - 05-14-2020

Hi,
Is it possible to pass an uploaded image file to a model for processing, something like:

PHP Code:
$file $this->request->getFile('image');
$id $this->request->getPost('id');
$image_use $this->request->getPost('image_use');
            
$process_image = new \App\Models\Admin\Image_manager;
$this->$data['result']=$process_image->save_image($file$id$image_use); 
Thanks in advance


RE: Ci4 Pass Uploaded Image from Controller to Model - jreklund - 05-14-2020

Yes, it's possible. The model are just a PHP-class like everything else. But you are trying to store it in your database? You should store it as a BLOB, but i don't recommend it. Keep it as a file.