a form that handles both image upload and text input - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: a form that handles both image upload and text input (/showthread.php?tid=31587) |
a form that handles both image upload and text input - El Forum - 06-24-2010 [eluser]Unknown[/eluser] Maybe I'm missing something, but there seems no way of coding a CI form that has both text input fields and a file upload input field. Seems simple enough. I have a CI form with validation, it has input fields for article title, description etc. I want to add an image upload field to this form. However the only examples/tutorials I can find have forms that only have an upload image field or forms that only have text,textarea etc type input fields. So there needs to be two forms with separate controllers, views and even model I guess. Is this right? a form that handles both image upload and text input - El Forum - 06-25-2010 [eluser]defectivereject[/eluser] [quote author="kiwiPrometheus" date="1277429308"]Maybe I'm missing something, but there seems no way of coding a CI form that has both text input fields and a file upload input field. Seems simple enough. I have a CI form with validation, it has input fields for article title, description etc. I want to add an image upload field to this form. However the only examples/tutorials I can find have forms that only have an upload image field or forms that only have text,textarea etc type input fields. So there needs to be two forms with separate controllers, views and even model I guess. Is this right?[/quote] You just need to open a multipartform Code: echo form_open_multipart('controller/function'); Code: echo "<br /> \n"; I'm extremely new to this but this is a part of a form i have, and how i handle it. I believe the NAME of your upload has to be userfile though. then in your controller just validate the upload and if that validates, validate your inputs and if they validate, then insert the data |