I can't to insert file_name image in database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: I can't to insert file_name image in database (/showthread.php?tid=57868) |
I can't to insert file_name image in database - El Forum - 04-20-2013 [eluser]Unknown[/eluser] That`s code is in my controller... i can`t to insert name of image in database, except to upload in directory /uploads/ code for insertion file_name of image is below: $data['file_name'] = $_POST['file_name']; please help me because needed for quickly.. thank you very much public function edit ($id = NULL) { // Fetch a article or set a new one if ($id) { $this->data['article'] = $this->article_m->get($id); count($this->data['article']) || $this->data['errors'][] = 'article could not be found'; } else { $this->data['article'] = $this->article_m->get_new(); } // Set up the form $rules = $this->article_m->rules; $this->form_validation->set_rules($rules); // Process the form if ($this->form_validation->run() == TRUE) { $data = $this->article_m->array_from_post(array( 'cat_id', 'title', 'url', 'body', 'pubdate' )); /* * upload */ $config['upload_path'] = 'c:/wamp/www/uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '1000'; $config['max_width'] = '10240'; $config['max_height'] = '7680'; $field_name = "file_name"; $this->load->library('upload', $config); if( $this->upload->do_upload($field_name)){ print "uploaded"; die("uploaded"); } else { $error = array('error' => $this->upload->display_errors()); print_r($error); die(); } //end of upload //insert file_name $data['file_name'] = $_POST['file_name']; $this->article_m->save($data, $id); } // Load the view $this->data['subview'] = 'admin/article/edit'; $this->load->view('admin/_layout_main', $this->data); } I can't to insert file_name image in database - El Forum - 04-26-2013 [eluser]Sudz[/eluser] Hi, How can you get file_name in $_POST? Use these lines after upload is success Code: $upload_data = $this->upload->data(); |