[SOLVED] File upload and form validation |
I'm trying to build a form with some input fields and a file upload field (for uploading an image).
In the controller, I set a few rules for the image, e.g. max_width and max_height. If the file upload is not succesful, I want to repopulate the form with the input fields, and display an error message at the top of the form, so the user can try again. How can I do that? I'm familiar with form_validation and the file upload library, but I can't combine the two. Any help is appreciated.
You need to create a custom callback and put the upload functionality there. And return TRUE if the upload works and FALSE otherwise. If it's true and you can't save it (the input fields in the database). You should delete the image. So make sure to set a variable you can access outside your upload validation with an absolute path, so you can delete it.
https://www.codeigniter.com/userguide3/l...on-methods |
Welcome Guest, Not a member yet? Register Sign In |