Welcome Guest, Not a member yet? Register   Sign In
No way to permit empty on file upload
#1

$Rules['image'] = ['label' => 'Image', 'rules'=>'uploaded[image]|is_image[image]|max_size[image.2048]'];


I am always getting an error for the image that is not an uploaded image file.

But i am not uploading any.

How can i make this rule permit empty. And only if something was set should validate the rules...

I tried with permit_empty, it does not work.
It doesn't show any validation errors if i upload a wrong image or exceed max file size or even if i upload another type of file that is not an image...
Reply
#2

(This post was last modified: 12-24-2021, 08:31 AM by mylastof.)

i have same issue

Im forgot to use : ` if ($files->hasFile('file_')) {`
Reply
#3

permit_empty
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

"permit_empty" is a rule for classic field form.
For file uploads, you need to use only Rules for File Uploads 
The rule to say if the file is required or not is : "uploaded".
If the file is required, add the rule : uploaded[file_name].
If it is optional, just do not add this rule.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB