Welcome Guest, Not a member yet? Register   Sign In
validate image file only when uploaded
#1

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'])){
    
validate();


is there any internal validation rule to achieve this?
premit_empty() ignore the whole validation
Reply
#2

Hi, we do have an file uploads rules, if that's what you are after?
https://codeigniter.com/user_guide/libra...le-uploads

Or you can write your own:
https://codeigniter.com/user_guide/libra...stom-rules
Reply
#3

$image = $this->request->getFile('input_fiee_name');

if($image->isValid)
{
//Your code here
}
Reply
#4

(08-22-2020, 03:28 AM)seunex Wrote: $image = $this->request->getFile('input_fiee_name');

if($image->isValid)
{
  //Your code here
}
I'm looking for an internal validation rule like premit_empty but for uploaded files.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB