Google에서 이것을 찾고 stackoverflow에서 다른 답변을 보았습니다. 그리고 거기에 probaly 그들에 좋은 답변이 있지만 여전히 내 자신의 코드에 그것을 함축 수있는 방법을 얻을하지 않습니다.Codeigniter 업로드 옵션
나는 이미지를 업로드하기 위해 내 자신의 공개 기능을 가지고 있지만, 이제는 선택 사항이되고 싶습니다. 이 순간 누군가가 유효성 검사를 통과하기 위해 파일을 업로드해야합니다.이 옵션을 어떻게 만들 수 있습니까?
내 기능 : 다른 사람들을 위해 사전--edit--
에서
public function _do_upload_image()
{
$config['upload_path'] = './company_images/';
$config['allowed_types'] = 'jpg|jpeg|png';
$this->load->library('upload', $config);
if (!$this->upload->do_upload())
{
$this->form_validation->set_message('_do_upload_image', $this->upload->display_errors());
}
else
{
$this->_upload_data = $this->upload->data();
}
}
덕분에, 대답은 일을하고 어떤 이미지가 없을 때 나는 다른 이름을 내 FILE_NAME을 준 업로드되었습니다. 그것은 다음과 같습니다 : 다음은
public function _do_upload_image()
{
$config['upload_path'] = './company_images/';
$config['allowed_types'] = 'jpg|jpeg|png';
$returnArr = array();
$this->load->library('upload', $config);
if (!$this->upload->do_upload())
{
$returnArr = array('file_name' => 'leeg.jpg');
}
else
{
$returnArr = $this->upload->data();
}
$this->_upload_data = $returnArr;
}
작동하지만 이미지가 업로드되지 않으면 [file_name] 값을 제공 할 수있는 방법이 있습니다. : leeg.jpg? – Augus
Uhm nvm, 내가 원하는 모든 기능으로 문제가 해결되었습니다. 아픈 내 게시물을 업데이 트하십시오! – Augus