드루팔에서 한글명 파일업로드시 오류 해결방안 문의

thjung99의 이미지

안녕하세요.

드루팔(Drupal, 오픈소스 CMS)로 사이트를 만들고 있는데,
첨부파일명이 한글인 경우에 업로드가 안되고 에러나 나고 있습니다.

구글링, kldp.org 사이트 검색 등 여러가지를 해 보았으나 명확한 해결책이 없는 것 같습니다.
"드루팔 사용하기"라는 책을 쓰신 분에게도 문의해 보았는데,
한글명을 영문으로 바꾸는(ex:학교 ==> hakgyo) module이 해결책 일것 같다 답변을 해 주셨고... ㅠㅠㅠㅠ,
한글명 파일을 완벽히 올리는 해결책을 아직도 못찾았습니다.

그런데 여기 사이트는 파일명이 한글이어도 잘 첨부가 되네요.
혹시 해결책을 아시는 분 알려주시면 감사드리겠습니다.

감사합니다.

thjung99의 이미지

여러가지를 해봐도 잘 안되네요.
혹시 아는 분 있으시면.. 답변부탁드립니다.

세벌의 이미지

http://palpal.org/ 에 물어보시면 혹시?

Prentice의 이미지

서버는 UTF-8? CP949? 어떻게 돌아가나요?

thjung99의 이미지

답변감사드립니다.

웹페이지 설정은 UTF-8입니다.

페이지 소스보면 이렇게 되어 있습니다.
charset=utf-8

Prentice의 이미지

해당 서버에서 파일시스템에 파일 이름을 저장할 때 뭘로 저장하나요?

해당 서버의 DB에는 한글이 뭘로 저장되나요?

thjung99의 이미지

file upload directory가 public이냐 private냐에 따라 해결방법이 좀 다르더군요.
업로드는 되는데 다운로드가 안되는 다양한 증상이 나타났는데,
다음과 같은 방법으로 해결했습니다.
댓글달아 주시고 도움주신분들께 감사드립니다.

한글 파일 인코딩 문제 해결 방법 – 파일이 private 경로에 저장 될 시
1. htdocs\includes\common.inc 파일 수정 function l($text, $path, array $options = array()) return 하기 전, path를 euc-kr 형태로 인코딩 -> $path = iconv(“UTF-8”, “EUC-KR”, $path); 문장을 추가함.

2. htdocs\includes\file.inc 파일 수정
*업로드 시 한글 파일명
function drupal_move_uploaded_file($filename, $uri)
파라미터로 넘어 온 $uri를 CP949로 인코딩 -> $uri = iconv(“UTF-8”,“CP949”,$uri); 문장을 추가함.

*다운로드 시 한글 파일명
function file_download()
1) if(file_stream_wrapper_valid_scheme($scheme)&&file_exists($uri))
->if (file_stream_wrapper_valid_scheme($scheme) && file_exists(iconv(‘UTF-8’, ‘cp949’, $uri))) 변경

2) if (count($headers)) { } 다음과 같이 추가

$headers = array( ‘Content-Type’ => ‘application/octet-stream’, ‘Content-Disposition’ => ‘attachment; filename=”’ . iconv(‘UTF-8’, ‘euc-kr’, $target) . ‘”’, ); if(strpos($_SERVER[‘HTTP_USER_AGENT’], ‘MSIE’)) { $headers[‘Cache-Control’] = ‘must-revalidate, post-check=0, pre-check=0’; $headers[‘Pragma’] = ‘public’; } else { $headers[‘Pragma’] = ‘no-cache’; }

function file_transfer()
1) $scheme = file_uri_scheme($uri); 의 $uri를 euc-kr 형태로 인코딩
-> $scheme = file_uri_scheme(iconv(UTF-8’, ‘euc-kr’, $uri));
2) if ($scheme && file_stream_wrapper_valid_scheme($scheme) && $fd = fopen($uri, ‘rb’)) {} 의 $uri를 euc-kr 형태로 인코딩
-> if($scheme && file_stream_wrapper_valid_scheme($scheme) && $fd =
fopen(iconv(‘UTF-8’, ‘euc-kr’, $uri), ‘rb’)) { }

김정균의 이미지

drupal의 charset을 euc-kr로 지정하셨나 보죠? 그냥 utf-8로 지정하시면 이렇게 고칠 이유가 별로 없을텐데요. 왠지 환경 문제 때문의 삽질일듯 싶습니다. ^^;

thjung99의 이미지

unicode로 처리해도 php가 한글은 제대로 처리를 못하는 것으로 알고 있습니다.
그래서...
어쩔 수 없이
삽질했습니다.
사실은 제가 한거는 아니구요.. 울 회사 동료가 고생 좀 했습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.