블로그 이미지
규미

Rss feed Tistory
wordpress 2011. 5. 18. 15:38

wordpress filetype unfiltering

wordpress에 파일 업로드시 확장자의 제한이 있다.

이를 해결하는 방법에는 플러그인 설치가 있으나 post 작성시 업로드에는 적용되지 않는다는 점이 있다.
후배 녀석도 같은 문제가 있어 단물만 빨아 먹을려고 했으나... 바쁘시단다....
그리하여 소스를 깟다..
업로드시 media, image 카테고리 분류는 확인 하지 못하였다.

아래와 같은 파일에서 다음과 같은 코드를 주석 처리한다.
unfilter list와 해당 파일의 확장자를 비교하여 필터링 하는 듯 하다.
unfilter list의 위치를 찾지 못하여? 필터체크하는 부분을 주석처리하였다.

./wp-admin/includes/file.php

//if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) )
//return call_user_func($upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' ));
-------------------------------------------------------------------------------------------------------------

unfilter list를 찾았다.(emeditor 다중파일 찾기로...)
아래 파일의 다음에 나온 코드에 확장자를 추가하면 된다.
./wp-admin/includes/schema.php

  'upload_filetypes' => 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf',


기타 팁으로는 확장자의 파일타입 출력을 지정할 수가 있다
./wp-includes/functions.php의 다음 함수에 코드를 추가하면 된다.
function get_allowed_mime_types() {
 static $mimes = false;
 if ( !$mimes ) {
  // Accepted MIME types are set here as PCRE unless provided.
  $mimes = apply_filters( 'upload_mimes', array( 'jpg|jpeg|jpe' => 'image/jpeg',



,
TOTAL TODAY