forms uploading image and text - 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: forms uploading image and text (/showthread.php?tid=51566) |
forms uploading image and text - El Forum - 05-09-2012 [eluser]andieevans[/eluser] Hi New to ci and the site. Working on a website where I want the user to upload an some information which can be text and or an image.. so I have a form with some text inputs and a single file input. I generated the form using the form helper echo form_input('myinput') echo form_submit('submit') and so on... trouble is I can see from my code that I am getting the text inputs data posted, but the file input appears to be blank... I have some code like this to see what is being posted: Code: print_r($this->input->post()); this is handy as I can see every form field and the value being sent. the problem I have is that even if I select a file, the file input is not listed in the array.... any ideas what could be up? forms uploading image and text - El Forum - 05-09-2012 [eluser]ojcarga[/eluser] Are you using form_open_multipart() to open <form ..> tag?? Here you can see about "form_open_multipart()" http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html Here some help with the file upload http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html forms uploading image and text - El Forum - 05-09-2012 [eluser]andieevans[/eluser] hi ojcarga thanks for the assist, yes i did use the form_open_multipart() to generate the form I also used form_close() forms uploading image and text - El Forum - 05-09-2012 [eluser]ojcarga[/eluser] I have worked uploading files just once but maybe this can help. I used this to create my inputs (VIEW FILE) Code: $cfile=array('name'=>'fileup', 'id'=>'fileup', 'value'=>'File'); My Controller Code: function upload_psd() { I had to add the ini_set directives cause my server did not let me uploads anything, maybe you don't need them. forms uploading image and text - El Forum - 05-12-2012 [eluser]andieevans[/eluser] hi thanks for the help I got it to work in the end... I was calling a model method from my controller to upload the file, and as such the reference to the file I wanted to upload was getting 'lost' I moved the upload code to the controller and it works fine. I am still able to send the form data to the database via the model method, just not the file. Thanks again. ;o) |