![]() |
Upload and insert file data in CodeIgniter - 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: Upload and insert file data in CodeIgniter (/showthread.php?tid=23501) |
Upload and insert file data in CodeIgniter - El Forum - 10-13-2009 [eluser]doubleplusgood[/eluser] Hi there, I'm creating a file upload in CodeIgniter, that uploads the file to the server and then stores some data in the database. I have a form that asks for a (friendly) file name and the file, which then uses my upload.php controller to upload the file to the server. Currently the actual upload of the file to the server is working, I just need to insert the (friendly) file name and the following from $data; file_name, file_type, file_ext and file_size. Here is my upload frunction in the upload controller; Code: function do_upload() Wondered if anyone has any pointers on how to get the above data into the database? Thank you. Upload and insert file data in CodeIgniter - El Forum - 10-13-2009 [eluser]Flemming[/eluser] print_r($data) to check what's in it first of all. Then build up a new array ready to insert into your db: Code: $insert = array( Code: $this->db->insert($insert); hope that's some help? Upload and insert file data in CodeIgniter - El Forum - 10-13-2009 [eluser]doubleplusgood[/eluser] @flemming Hey, thanks for the reply. I just got a solution working using the following code; Code: $data = array('upload_data' => $this->upload->data()); Not sure whether this is the right way to do things as it does seem rather verbose. ![]() |