Friday, December 31, 2021

[FIXED] How to check if file field is empty in codeigniter?

Issue

I have a form with a file field called image, but this field is not required.
When user don't choose any file in form, the do_upload() always return a error.
How can I check if user chosen a file before perform the upload action in my controller?


Solution

Please use empty()

if (empty($_FILES['userfile']['name'])) {
}


Answered By - Vinoth Babu

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.