Required Validation for file field |
[eluser]_steve[/eluser]
I'm trying to apply required validation to a file upload field. Usually on a text field this would be: Code: $this->form_validation->set_rules('name', 'Name', 'required'); Any ideas?
[eluser]mi6crazyheart[/eluser]
Can't understand , if u r uploading any file then why using form validation class rather file uploading class... For file uploading: http://ellislab.com/codeigniter/user-gui...ading.html
[eluser]gyo[/eluser]
Have you tried on different browsers? Sometimes there are problems with the MIME types. Hope it helps!
[eluser]danmontgomery[/eluser]
file uploads are passed through $_FILES, not $_POST or $_GET as other form data, so this will not work.
[eluser]_steve[/eluser]
Thanks for the replies. I'm using the validation class because I want to validate all the fields before I bother uploading the image. I've tried on different browsers and get the same result. Taking what noctrum said about $_FILES, I tried to create a custom validation rule, however its still not working, anyone see where I'm going wrong? Code: //... from a validate function with the other rules
[eluser]Unknown[/eluser]
Hi! You need to put this function in a controller| helper and try to call it by callback_. It will work
[eluser]davidbehler[/eluser]
As far as I know you can't validate file uploads using the form_validation library. You should use the upload library for that or search the forum, because someone created an extended version of the form_validation library that supports file upload validation. Maybe this is what you are looking for: http://ellislab.com/forums/viewthread/123816/ |
Welcome Guest, Not a member yet? Register Sign In |