Problems with Form_Validation and Upload LIbraries |
[eluser]Sheikh Aman Alam[/eluser]
Hello. i was wondering to know if there is a way to valida that- a space wasn't put in the form field that has been posted. i can use "alpha_dash", but i want to allow dot(.) and @ as well. theres a segment in user guide that tells u can use php functions as validation function/rules too. how to do that? second thing, iam using upload library to upload images. amazing library! but is there any way to ignore the error if the user hasn't uploaded any image? it makes the user to upload the image as a mandatory field, while that is not a requirement. Please assist.
[eluser]LuckyFella73[/eluser]
Hi, Quote:i can use “alpha_dash”, but i want to allow dot(.) and @ as well. In case you want to validate an email address you can use the "valid_email" rule. Otherwise you can write your own callback-functions additionally to the build-in validation functions. User Guide // Callback About your file upload question: Check if a file was selected for uploading like this: Code: if($_FILES['userfile']['size'])
[eluser]Sheikh Aman Alam[/eluser]
Thanks a lot for the link about callback functions. it will work. i'll try that soon. Code: if($_FILES['userfile']['size']) im using the 'upload' library of codeigniter, not PHP's core file upload mechanism, i wanted to know in that.
[eluser]LuckyFella73[/eluser]
Code: if($_FILES['userfile']['size']) This line is just to check if a file was selected to upload. If there is a file you go on with the codeigniter fileupload class! A bit more detailed: Code: if($_FILES['userfile']['size'])
[eluser]Sheikh Aman Alam[/eluser]
ohk.. so u mean to say that the library doesn't provide any way of doing so, i'll have to use php's methods. rest of it i already know. Thanks for ur help dear!
|
Welcome Guest, Not a member yet? Register Sign In |