질문 Q #11062
hwp 파일 업로드 mime 설정
찐냥 2014-01-03 13:36:17
if($_FILES['file_info']['name']){
 $config['upload_path'] = $GLOBALS['path'];
 $config['file_name'] = strtolower($_FILES['file_info']['name']);
 $config['allowed_types'] = 'gif|jpg|png|txt|xlsx|xls|ppt|pptx|doc|pdf|hwp';
 $config['max_size'] = '10240';    //10mb
 $config['max_filename']  = '100';
 $config['file_field'] = 'file_info';
 $config['remove_spaces'] = FALSE;

 $this->load->library('upload', $config);
                
 if (!$this->upload->do_upload($config['file_field'])) {
  $file_error = $this->upload->display_errors();
 }else{$file_error = '';}
}

if($file_error){
 echo $_FILES['file_info']['type'];
 $file_error = str_ireplace("</p>","",str_ireplace("<p>","",$file_error));
 echo "<script type='text/javascript'>alert('$file_error');history.go(-1);</script>";
 return FALSE;
}
위와같이 파일 업로드를 구현합니다.
다른 확장자는 아무런 에러 없이 잘 올라가는데 hwp 파일만 올리면
'업로드하려는 파일 유형은 허용되지 않습니다.' 라는 에러가 나오네요.
에러 에코 출력물에도 application/haansofthwp 라고 나오는데 말이죠..

mimes.php 파일에도 처음엔 application/haansofthwp 하나로 시작해서
'hwp' => array('application/haansofthwp', 'application/x-hwp', 'application/unknown', 'application/msword', 'application/octet-stream', 'application/zip', 'text/plain', 'text/xml'),
와 같이 온갖 설정 죄다 적어줘도 안되네요..
pptx는 'application/vnd.openxmlformats-officedocument.presentationml.presentation' 적어주고 바로 적용했는데 말이죠..

php 버전은 5.4.23 입니다.

도움말씀 부탁드립니다..
답변 4
#1 변종원(웅파) 2014-01-03 14:00:20
echo mime_content_type('test.php');

이 함수로 서버에 파일 올려놓고 출력해보세요.
뭔가 다른게 나올지도.... ^^;;


#2 찐냥 2014-01-03 14:22:37
웅파님 답변 정말 감사드립니다.. ㅎㅎ
'application/CDFV2-corrupt' 라는 값이 나와서 소문자 변환해 적용하였습니다. 정말 감사드립니다!!
#3 dfd. 2014-01-05 22:13:43
 hwp 적용할려다 실패해서 그냥 allowed_types를 *로 했던 기억이 나는데.. -_-;;
저것도 있었군요 . 메모해 둬야 겠습니다 잘 봤습니다~
#4 조현 2016-07-02 02:00:38
CI hwp 파일 업로드 http://bluebreeze.co.kr/991