Upload and insert file data in CodeIgniter |
[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.
[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?
[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. |
Welcome Guest, Not a member yet? Register Sign In |