| 제목 | 파일업로드시 타입 에러 | ||
|---|---|---|---|
| 글쓴이 | 변종원(웅파) | 작성시각 | 2010/05/13 15:39:52 |
|
|
|||
|
Upload 라이브러리 이용하여 업로드시 분명히 맞는 파일타입임에도 업로드가 되지 않을때가 있습니다. $allow_type = array('jpg', 'zip'); //이렇게 이미지가 먼저 나올 경우 에러가 납니다. 원래 core를 건드리지 않는다가 철칙이지만 버그인 경우는 어쩔 수 없이 손을 댑니다. system/libraries/Upload.php 파일의 다음함수를 바꿔주시면 됩니다.
/**
* Verify that the filetype is allowed
*
* @access public
* @return bool
*/
function is_allowed_filetype()
{
if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types))
{
$this->set_error('upload_no_file_types');
return FALSE;
}
//kofic - hacking - start
$ext_found = 0;
$ext = $this->file_ext;
$ext = str_replace(".","",$ext);
//kofic - hacking - end
$image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe');
foreach ($this->allowed_types as $val)
{
//kofic - hacking - start
if ( strtolower($val) == strtolower($ext) ){$ext_found = 1;}
//kofic - hacking - end
$mime = $this->mimes_types(strtolower($val));
//kofic - hacking - start
// Images get some additional checks
//kofic - commenting original code - start
//if (in_array($val, $image_types))
//kofic - commenting original code - end
if (in_array($ext, $image_types))
//kofic - hacking - end
{
if (getimagesize($this->file_temp) === FALSE)
{
return FALSE;
}
}
if (is_array($mime))
{
if (in_array($this->file_type, $mime, TRUE))
{
return TRUE;
}
}
else
{
if ($mime == $this->file_type)
{
return TRUE;
}
}
}
//kofic - hacking - start
if ( $ext_found ){ return TRUE; }
//kofic - hacking - end
return FALSE;
}
|
|||
| 다음글 | codeigniter Asset helper (4) | ||
| 이전글 | 다중 데이터베이스 접속 및 모델, 프로파일러 확장 (2) | ||
|
배강민
/
2010/05/13 16:01:13 /
추천
0
|
|
kirrie
/
2010/05/13 16:10:03 /
추천
0
ㅎㅎㅎ 저도 며칠전에 이거 발견하고 수정했는데. ㅋㅋ
이 업로드 클래스가 웃긴게 이미지가 아니어도 굳이 이미지 파일인지 아닌지 검사하려고 그러던 거였더라구요. |
|
케이든
/
2010/05/13 16:12:31 /
추천
0
좋스빈다!!
코어를 안건드리고 확장해서 메쏘드를 오버라이딩 하면 되지 않을까요? |
|
kirrie
/
2010/05/13 16:18:58 /
추천
0
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Upload extends CI_Upload {
function MY_Upload($props = array())
{
parent::CI_Upload($props);
}
/**
* Verify that the filetype is allowed
*
* @access public
* @return bool
*/
function is_allowed_filetype()
{
if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types))
{
$this->set_error('upload_no_file_types');
return FALSE;
}
$image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe');
foreach ($this->allowed_types as $val)
{
$mime = $this->mimes_types(strtolower($val));
// Images get some additional checks
if (in_array($val, $image_types) && $this->is_image() === TRUE)
{
if (getimagesize($this->file_temp) === FALSE)
{
return FALSE;
}
}
if (is_array($mime))
{
if (in_array($this->file_type, $mime, TRUE))
{
return TRUE;
}
}
else
{
if ($mime == $this->file_type)
{
return TRUE;
}
}
}
return FALSE;
}
// --------------------------------------------------------------------
}
/* End of file */전 이렇게 수정해서 확장했습니다. |
|
변종원(웅파)
/
2010/05/13 16:29:00 /
추천
0
키리에/ 땡유. ^^
|
아.. 그렇군요.. 아직 파일 업로드까진 안해봐서리... 캄사합니다...2.0에서는 해결될라낭...