validate image file only when uploaded - 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: validate image file only when uploaded (/showthread.php?tid=77361) |
validate image file only when uploaded - pars1997 - 08-21-2020 Hi I need to validate an image file only if it was uploaded by the user. I know I can use something like: PHP Code: if(isset($_FILE['image'])){ is there any internal validation rule to achieve this? premit_empty() ignore the whole validation RE: validate image file only when uploaded - jreklund - 08-22-2020 Hi, we do have an file uploads rules, if that's what you are after? https://codeigniter.com/user_guide/libraries/validation.html#rules-for-file-uploads Or you can write your own: https://codeigniter.com/user_guide/libraries/validation.html#creating-custom-rules RE: validate image file only when uploaded - seunex - 08-22-2020 $image = $this->request->getFile('input_fiee_name'); if($image->isValid) { //Your code here } RE: validate image file only when uploaded - pars1997 - 08-25-2020 (08-22-2020, 03:28 AM)seunex Wrote: $image = $this->request->getFile('input_fiee_name');I'm looking for an internal validation rule like premit_empty but for uploaded files. |