form_open_multipart with form_validation - am I missing something or is it a bug ? |
[eluser]DeaD SouL[/eluser]
Hello This example doesn't want to work.. It keeps saying Quote:The File field is required.even if I removed the validation rule, it just show me the form again and again.. Am I missing something here ? CI ver: 2.0.2 controller: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); view: Code: <!DOCTYPE html> Thanks
[eluser]davidbehler[/eluser]
You can't check for inputs with type="file" via the form validation library. It only validates what's in the $_POST array and file upload info will be in $_FILES. Have a look at the file uploading class (http://ellislab.com/codeigniter/user-gui...ading.html) instead, maybe that'll help you.
[eluser]DeaD SouL[/eluser]
You're right.. but as i said: Quote:even if I removed the validation rule, it just show me the form again and again.. the upload class is great,.. but I just wonder why I can't use the form_validation library with <input type="file" /> ?? aw, thanks bro
[eluser]davidbehler[/eluser]
To answer your first question: The test_files view is loaded everytime you submit the form because no validation rules = is not valid, meaning $this->form_validation->run() always returns FALSE. To answer your second question: Because it doesn't support it The lib doesn't know what type of input the fields are you set the rules for. It loops through all the rules and checks $_POST for each field according to what rules you defined, e.g. trim|required|valid_email. Now in case of an input with type="file", it'll not appear in $_POST but rather in $_FILES (but the form validation lib doesn't check that one). Some time back I read about an extended version of the form validation that actually works with file uploads, but I haven't used it yet. I'm still kickin' it old school by combining form validation with file uploading and works fine for me so far.
[eluser]DeaD SouL[/eluser]
Right,.. You made me check the form_validation::run() Code: [....] Thanks waldmeister |
Welcome Guest, Not a member yet? Register Sign In |