ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 워드프레스 hwp. zip과 같은 파일을 업로드 하고 싶을 때 해결방법
    워드프레스 2016. 3. 3. 10:29
    336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

    워드프레스는 파일을 첨부할때 지정된 파일타입 이외에는 업로드를 허용하지 않고 있다. 이런 이유로 흔히 사용하는 아래한글( hwp) 파일이나 zip파일 형식 등을 업로드하면 에러가 나타난다. 당연할지도 모른다, 우리나라 한글 워드프로세서를 알리 만무 하니까!


    그래서 우리가 흔히 사용하는 파일을 업로드 하려고 방법을 찾아보니 다음과 같이 처리하면 되다는 정보를 얻었다.


    첫 번째 방법


    플러그인을 사용하는 방법


    1. 사용법 아래의 링크에 접속해 플러그인을 설치한다.

    2. 옵션에서 우측 온, 오프 버튼을 눌러 업로드할 파일 타일을 켜거나 껀다. 


    플러그인 경로 : https://wordpress.org/plugins/rocket-media-library-mime-type/



    두 번째 방법


    업로드할 파일 형식을 소스에 추가하는 방법



    수정할 파일 : ../wp-content/themes/사용테마/functions.php

    child 테마 사용시 : ../wp-content/themes/사용테마-child/functions.php



    1. 워드프레스 wp-includes폴더에 있는 functions.php를 열어 upload_mimes을 검색한다.

    2. $mimes = apply_filters( ‘upload_mimes’, array( 줄을 찾는다.

    3. 바로 아래줄에  ‘확장명(hwp)’ => ‘파일타입(application/hangul)’,을 추가한다. 

    4. 알집 파일도 업로드 하려면 다시 hwp추가한 아래 줄에 .alzegg => application/alzip'.과 같이 필요한 내용을 추가할 수 있다.


    즉 새롭게 업로드하기를 원하는 파일의 종류가 있으면 확장명과 파일타입을 위와 같이 추가해 주고 저장하면 된다는 것이다.


    위에서 설명한 내용은 보면 아래와 같다.


    functions.php 해당하는 소스코드 부분


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    function get_llowed_mime_types( ) {
       static $mimes=false;
     
    if (!$mimes) {
    // Acceped MIME Type are ser here as PCRE unless provided.
    $mimes=apply_filters ('upload mimes', arrary(
    'jpg|jpeg|jpe'=> 'images/jpeg',
    'gif' => images/gif',
    'png' => images/png',
    'bmp' => images/bmp',
    'tif|tiff' => 'iamges/tiff',
    'ico' => 'images/x-icon',
    'asf|asx|wax|wmv|wmx' => 'video/asf',
    cs



    functions.php 해당하는 소스코드 수정된 부분


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    function get_llowed_mime_types( ) {
       static $mimes=false;
     
    if (!$mimes) {
    // Acceped MIME Type are ser here as PCRE uniess provided
    $mimes=apply_filters ('upload mimes', arrary(
    'hwp' => 'application/hangul',
    'alz|egg' => 'application/alzip'
    'jpg|jpeg|jpe'=> 'images/jpeg',
    'gif' => images/gif',
    'png' => images/png',
    'bmp' => images/bmp',
    'tif|tiff' => 'iamges/tiff',
    'ico' => 'images/x-icon',
    'asf|asx|wax|wmv|wmx' => 'video/asf',
    cs



    댓글

Designed by Tistory.