| 제목 | 파일 업로드시 A PHP Error was encountered 가 납니다. | ||
|---|---|---|---|
| 카테고리 | CI 2, 3 | ||
| 글쓴이 | 럭셔리얼라 | 작성시각 | 2017/06/09 09:40:34 |
|
|
|||
|
CI 3일째가 그대로 연장되는 4일차 입니다. 어제 경로문제를 질문드렸는데 경로는 문제가 없었구요. 파일 업로드시 저장도 제대로 되고 원하는 파일정보도 뷰에 출력이 되는데 제목과 같은 에러도 함께 나옵니다.
에러내용은 ====================================================================== A PHP Error was encountered Severity: Warning Message: finfo_open() [function.finfo-open]: Failed to load magic database at '/usr/share/misc/magic'. Filename: libraries/Upload.php Line Number: 1008 ======================================================================= 이러하구요. 제가원하는 값은 array(14) { ["file_name"]=> string(36) "3c4d40cdeb2ff59a0cefb0aa5389106e.jpg" ["file_type"]=> string(10) "image/jpeg" ["file_path"]=> string(40) "/home/haeho77/www/uploadFile/boardImage/" ["full_path"]=> string(76) "/home/haeho77/www/uploadFile/boardImage/3c4d40cdeb2ff59a0cefb0aa5389106e.jpg" ["raw_name"]=> string(32) "3c4d40cdeb2ff59a0cefb0aa5389106e" ["orig_name"]=> string(15) "mainbanner1.jpg" ["client_name"]=> string(15) "mainbanner1.jpg" ["file_ext"]=> string(4) ".jpg" ["file_size"]=> float(26.91) ["is_image"]=> bool(true) ["image_width"]=> int(740) ["image_height"]=> int(120) ["image_type"]=> string(4) "jpeg" ["image_size_str"]=> string(24) "width="740" height="120"" } 위와 같이 잘 넘어 옵니다. 위 파일 정보만 불러와야 되는데 상위 에러까지 출력이 되어 버리니 제대로 동작이 안되는거 같습니다.
일반 PHP를 그대로 CI로 옮기는 작업이기 때문에 뷰단은 문제가 없을꺼 같아 메소드 부분만 올려 봅니다.
컨트롤러===========================
public function imgupload(){
$config['upload_path'] = './uploadFile/boardImage';
$config['allowed_types'] = 'gif|jpg|png|zip'; // git,jpg,png 파일만 업로드를 허용한다.
$config['max_size'] = '0'; // 허용되는 파일의 최대 사이즈 0은 서버설정
$config['max_width'] = '0'; // 이미지인 경우 허용되는 최대 폭
$config['max_height'] = '0';// 이미지인 경우 허용되는 최대 높이
$config['remove_spaces'] = 'TRUE';// 공백을 _(언더바)로 대체
$config['encrypt_name'] = 'TRUE';// 파일이름 암호화
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload("file"))
{
$error = array('error' => $this->upload->display_errors());
var_dump($error);
}
else
{
$data = $this->upload->data();
foreach($data as $key=>$val){
$orig_name = element('orig_name', $data);
$file_name = element('file_name', $data);
$file_type = element('file_type', $data);
$file_path = element('file_path', $data);
}
//$data = $this->upload->data();//파일정보
var_dump($data);exit;
$uploadFile = $file_path.$file_name;
echo json_encode(array('success' => true, 'save_url' => $uploadFile ));
$this->load->view('upload_success', $data);
}
}//imgupload
저 에러가 무슨뜻이며 왜 나는 걸까요? 감사합니다.
|
|||
| 다음글 | htaccess 관련 (6) | ||
| 이전글 | 경로에서 값 읽어오기 질문입니다. (2) | ||
|
변종원(웅파)
/
2017/06/09 10:14:03 /
추천
0
|
|
럭셔리얼라
/
2017/06/09 10:21:29 /
추천
0
아...확인해 보니 php 5.21버젼이네요. 공부용으로 호스팅한지 오래돼서....업체에 문의해보겠습니다. 감사합니다. |
|
kaido
/
2017/06/09 10:55:49 /
추천
0
깡패24 아직도 5.2 인가 보군요.... CI 2.7 버전으로 사용 하셔야 합니다. |
|
닉
/
2017/06/09 11:15:58 /
추천
0
카페24 가보니 php 버전 여러개 지원 하네요. 7버전도 제공하네요 |
|
전상민
/
2017/06/09 12:19:44 /
추천
0
저희 회사에선 PHP4 ~ PHP7 까지 서버 환경을 선택할 수 있게 제공하고 있네요. https://www.cafe24.com/?controller=product_page&type=basic&page=autoban |
사용하시는 업로드 라이브러리 필요요건을 찾아보세요. 특정 라이브러리가 있어야 한다거나 하는 걸 말합니다.
라이브러리에서 finfo_open() 이라는 함수를 사용하는데 php5.3 이상이어야 합니다. 서버의 php 버전 확인해보시고
로컬과 서버의 설치된 php extension 비교해보세요. echo phpinfo(); 로 출력해서 비교해보세요.
로컬에만 설치된 extension이 있다면 서버에도 설치해주셔야 합니다.