2016-07-17 21 views
0

フォルダに画像を追加できません。その理由はわかりません。私は自分のルートフォルダ内に顧客フォルダを持っています。codeigniterの画像フォルダをアップロードできません

これは私のコントローラ機能である:

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']); 
} 

答えて

1

アップロードパスは、ここで設定しようとしたURLの値ではありません。ファイルシステムへの絶対パスまたは相対パスです。

$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

+0

私の詳細はデータベースにアップロードされますが、フォルダーはありません...私は$ config ['upload_path'] = site_url() 'customer /'を変更します。 $ config ['upload_path'] = FCPATH.'customer/'に変更してください。しかし、同じ問題.... @ Tpjka –

+0

私はあなたに提案し、そこに何か違いがあると言って 'のupload_path'を変更します。 – Tpojka

+0

ありがとうございました........ @ Tpojka –

0
$config['upload_path'] = './customer/'; 

ただし、プロジェクトには「顧客」という名前のフォルダが必要です。