Welcome Guest, Not a member yet? Register   Sign In
File upload with additional form validation
#1

[eluser]Loquela[/eluser]
Hi there,

I want to create an upload form that allows the user to include information (title, description)about the file. I want to store this info in a along with the filename in a databese.

What's the best way to do this so I can validate the additional user input as well as file upload and retain the set_value functionality for the additional fields?

Thanks in advance,

Loquela
#2

[eluser]pickupman[/eluser]
It works similar to here on the boards. The uploading part of things use the $_FILES array when posting data to the server, but form validation only works on $_POST. What you will need to do is decide what half you want to check first. I would suggest the upload part, as it the most data, and you don't need users uploading files more than once. Once you use the upload class to make sure the file is uploaded, add it to the db, and save record id. Now run your validation code. If validation passes, update the previous record with form data. If validation fails, return a form with possibly a thumbnail for the image so the user remembers the image, pass a record id as a hidden field perhaps. When the user submits the form again, check for the hidden id, and if validation passes update record in db.




Theme © iAndrew 2016 - Forum software by © MyBB