Storing image filename to DB along with other data - 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: Storing image filename to DB along with other data (/showthread.php?tid=53727) |
Storing image filename to DB along with other data - El Forum - 08-06-2012 [eluser]RockyS[/eluser] Hello, I have a form with multiple inputs (text) and one file input(for images) what I would like to do is to store image filename to DB with other submitted data, this is my controller http://pastebin.com/K6s34xRe and my model http://pastebin.com/9ddj4uTX (method "dodaj_sliko() is save_image() in english) My field for files is Code: <input type="file" name="file_upload_manual_slike" multiple /> So the main question is, how can I accomplish this, because above code that I posted doesn't work :-S Storing image filename to DB along with other data - El Forum - 08-06-2012 [eluser]Oscar Dias[/eluser] Hi, I think that your upload is not executed because it is right after a redirect: Code: redirect($this->config->item('base_url'), 'refresh'); The redirect function has an exit, which means it will stop execution after it. Code: function redirect($uri = '', $method = 'location', $http_response_code = 302) You need to do the upload before the redirect. Storing image filename to DB along with other data - El Forum - 08-07-2012 [eluser]ppwalks[/eluser] are you using codeigniters upload class if so you pass the variable to the model like this, here is mine using "do_upload": Model: Code: function add_product($file_name) { Code: if (!empty($_FILES['product_thumb'])) Code: $this->MProducts->add_product($file_name); |