2017-05-03 1 views
0

폴더에 이미지를 업로드하고 filename을 MySQL에 삽입해야하며 이미지 이름은 고유해야합니다. 내 컨트롤러 코드는 다음과 같습니다폴더에 이미지를 업로드하고 데이터베이스에 삽입하는 방법 CodeIgniter 프레임 워크에서

if ($_SERVER['REQUEST_METHOD'] == 'POST') 
{ 
    $config['upload_path'] = 'uploads/gallery/'; 
    $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg'; 
    $this->load->library('upload', $config); 
    $upload = $this->upload->do_upload('image_file'); 
    $title=$this->input->post('title'); 
    $value=array(
     'title' => $title, 
     'image_name' => $new_image_name, 
     'crop_name' => $crop_image_name 
    ); 
} 

답변

0

public function uploadImageFile() //gallery insert 
{ 
    if($_SERVER['REQUEST_METHOD'] == 'POST') { 
    $new_image_name = time() . str_replace(str_split('()\\/,:*?"<>|'), '', 
    $_FILES['image_file']['name']); 
    $config['upload_path'] = 'uploads/gallery/'; 
    $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg'; 
    $config['file_name'] = $new_image_name; 
    $config['max_size'] = '0'; 
    $config['max_width'] = '0'; 
    $config['max_height'] = '0'; 
    $config['$min_width'] = '0'; 
    $config['min_height'] = '0'; 
    $this->load->library('upload', $config); 
    $upload = $this->upload->do_upload('image_file'); 
    $title=$this->input->post('title'); 
    $value=array('title'=>$title,'image_name'=> 
    $new_image_name,'crop_name'=>$crop_image_name);} 
+0

같이 할 thanku @ sooraj subramanyan –

+0

여기 $ new_image_name 변수 값은 고유 –

관련 문제