2016-06-02 3 views
1

codeigniter에서 이미지를 업로드하고 싶습니다. 그러나 이름이 바뀐 이미지를 업로드하는 방법은 아래 코드를 참조하십시오.codeigniter에서 이름이 변경된 이미지를 업로드하는 방법

$filename = $_FILES['filename']['name']."_".date("Y-m-d")."_".date("H:i:s"); 

public function index() 
{ 
    $this->form_validation->set_rules('title', 'Title', 'required'); 
    $this->form_validation->set_rules('description', 'Description', 'required'); 
    $this->form_validation->set_rules('author', 'Author', 'required'); 

    $filename = $_FILES['filename']['name']."_".date("Y-m-d")."_".date("H:i:s"); 

     $this->do_upload(); 

     $this->load->model('News_model'); 
     $this->News_model->insert_news($filename); 

     $this->load->view('news/success', $data);  
} 
+0

당신이 당신의 문제에 대한 해결책을 찾았나요 :

$folder = "./Path/To/Uploaded/files" $config['upload_path'] = $folder; // We initiate the CI upload library $this->load->library('upload', $config); if (!$this->upload->do_upload('file')) { $error = array('error' => $this->upload->display_errors()); } else { // Upload success, we get back the image info $data = array('upload_data' => $this->upload->data()); // we rename the file $filename = $data['upload_data']['raw_name'] . "_".date("Y-m-d") . "_" . date("H:i:s") . $data['upload_data']['file_ext']; rename($data['upload_data']['full_path'], $folder . $filename); } 

는 앨리스 랩 문서에서 자세한 내용을 참조하십시오? –

답변

관련 문제