Reputation: 72
I cannot add image to the folder, I don't know why. I have customer folder inside my root folder.Need help.
This is my controller function:
function add_new_successfully(){
$config['upload_path'] = site_url().'customer/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$this->load->library('upload',$config);
$this->upload->do_upload('userfile');
$data['customer_name'] = $this->input->post('c_name');
$data['customer_email'] = $this->input->post('c_email');
$data['customer_pass'] = $this->input->post('c_pass');
$data['customer_country'] = $this->input->post('c_country');
$data['customer_city'] = $this->input->post('c_city');
$data['customer_contact'] = $this->input->post('c_contact');
$data['customer_address'] = $this->input->post('c_address');
$data['customer_image'] = $_FILES['userfile']['name'];
$this->common_model->insert('customers',$data);
$this->session->set_flashdata('page_added','<div class="n_ok"><p>Customer added</p></div>');
redirect($_SERVER['HTTP_REFERER']);
}
Upvotes: 0
Views: 625
Reputation: 150
$config['upload_path'] = './customer/';
but you need to have a folder called "customer" in the project.
Upvotes: 0
Reputation: 7111
Upload path is NOT an URL value which you tried to set here. It is an absolute or relative path to the file system.
$config['upload_path'] = FCPATH.'customer/';//FCPATH is constant for file system path to root directory or better said path to location next to index.php file
Docs.
Upvotes: 1