Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] File upload and form validation

(This post was last modified: 10-24-2018, 11:02 AM by Wouter60.)

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.

(This post was last modified: 10-23-2018, 01:40 PM by jreklund.)

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.


Thanks jreklund, i'll give it a try.

Works like a charm now!

Theme © iAndrew 2016 - Forum software by © MyBB