KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
im trying to write a code where i can submit a form enter the contents in a database, at the same time perform a file upload and have it stored in a folder inside my server the folder location is called uploads which is located at the root of my site here is my code controller (site.php) <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Site extends CI_controller { public function __construct() { parent::__construct(); // Your own constructor code $this->load->model("site_model"); $this->load->helper(array('form', 'url')); } public function cmain($type,$page) { $data = $this->_initialize_data(); //this is just a bunch of variables that im calling in another function $data['type'] = $type; $data['page'] = $page; $this->load->vars($data); $this->load->view('site/cmain'); } public function m1() { $this->load->library('upload', $config); if(isset($_POST['m1'])) { $suffix = $this->input->post("suffix"); $fn = $this->input->post("fn"); $mn = $this->input->post("mn"); $ln = $this->input->post("ln"); $newdata = array('suffix'=>$suffix, 'fn'=>$fn, 'mn'=>$mn, 'ln'=>$ln, ); //this code is for the file upload $config['upload_path'] = 'uploads'; $config['allowed_types'] = '*'; $this->load->library('upload', $config); $data = array('upload_data' => $this->upload->data()); //end of file upload codes $this->db->insert('myself', $newdata)
Tags (comma-separated)
Save Edits
Cancel