![]() |
form validation - show upload errors - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: form validation - show upload errors (/showthread.php?tid=63271) |
form validation - show upload errors - Lykos22 - 10-14-2015 I'd like some help please. I', having a contact form in which I can also upload files. I have set up the form validation and the uploading configuration according to the documentation, however I have spotted a "logic" problem. If I submit all the form fields with valid data and select an invalid type file to upload, the form process works as correct, and redirects to my "thank you" page, whereas I should get the error message from the invalid file upload. I 'm assuming this is because the upload errors are not part of the form_validation library or the two libraries don't "communicate" some way. How can I fix this bug ? This is my code PHP Code: protected $rules = array( RE: form validation - show upload errors - mwhitney - 10-14-2015 If you want your validation of the file upload to be part of the form validation, you should create a validation rule to perform the file upload/validation. In other words, you could do something like this: PHP Code: protected function where_you_run_the_validation() RE: form validation - show upload errors - Lykos22 - 10-15-2015 @mwhitney Thank you for your help! I tried it and its working! I didn't think of using callbacks, actually I started doing this using sessions, so this saved me some time! |