CI 묻고 답하기

제목 혹시 CI에 네이버 스마트에디터 2.0 설치 해 보신 분 계세요?
글쓴이 닥스훈트 작성시각 2012/06/29 21:54:21
댓글 : 4 추천 : 0 스크랩 : 0 조회수 : 27450   RSS
 네이버의 위지웍 웹 에디터인 '스마트 에디터 2.0' 을 일단 CI로 생성한 폼에 붙이는 것 까진 성공했고

스마트 에디터로 생성한 텍스트 문서는 그대로 저장되는 거 까진 확인했습니다만

사진 퀵 업로더(사진 전송 부분)는 이해가 되질 않네요. 

스마트 에디터 개발자 페이지의 메뉴얼 (  http://jindo.dev.naver.com/smarteditor/user_guide/  ) 을 봐도

이해가 되질 않는데 혹시 사진 퀵 업로더도 설치 성공하신 분들...

설치기나 강좌 같은걸 좀 올려주실 수 있을런지....


 다음글 group_by에서 날짜 필드는 어떻게? (1)
 이전글 CI Layout 질문 드립니다 (12)

댓글

슈럭 / 2012/07/02 15:42:40 / 추천 0
간단히 해보긴 해봤습니다만...
제가 원하는 가장 중요한 기능인 게시판별 저장 디렉토리 변경이라는 기능은 없더군요.
일단은 날짜별로 한군데로 몰아 넣는 것 까지는 성공 했습니다.

스마트 에디터 개발자 페이지의 메뉴얼을 보고 그대로 따라하신 다음.....
일반 자료실에 올릴랬더니... 코드가 안먹네요...

다음 댓글을 확인하세요...
좋은 소스는 아니지만 도움이 되길바랍니다.
슈럭 / 2012/07/02 16:57:43 / 추천 0

이것은 html5를 사용하지 못하는 경우 사용되는 페이지에서 전송시 파일이 저장되는 페이지입니다.....
SmartEditor/popup/quick_photo/FileUploader.php

<?php
function get_extension($filename)
{
 $x = explode('.', $filename);
 return '.'.end($x);
}

function make_dirs($path, $last_is_file=FALSE){

 $dir_arr = explode("/", $path);
 
 if (empty($dir_arr[0])){
  $path = "";
 }elseif($dir_arr[0] == "." || $dir_arr[0] == ".."){
  $path = realpath($dir_arr[0]);
  $dir_arr[0] = "";
 }else{
  $path = "/";
 }

 foreach ($dir_arr as $dir) {
  $dir = trim($dir);
  if (!$dir) continue;

  if ($last_is_file) {
   if ($dir == $dir_arr[count($dir_arr)-1]) {
    return false;
   }
  }

  if (isset($path)) $path .= "/".$dir; else $path = $dir;
  if (@is_dir($path)) continue;

  @mkdir($path, 0707);
  @chmod($path, 0707);

  if(! @copy(VIEW_PATH.'/index.html', $path . '/index.html')){
   $file = $path . "/index.html";
   $f = @fopen($file, "w");
   @fwrite($f, "<html><head><title>403 Forbidden</title></head><body><p>Directory access is forbidden.</p></body></html>");
   @fclose($f);
   @chmod($file, 0606);
  }
 }
}

//기본 리다이렉트
echo $_REQUEST["htImageInfo"];

$UPLOAD_DIR = 'upload/'.date('Ymd');


$url = $_REQUEST["callback"] .'?callback_func='. $_REQUEST["callback_func"];</p><p>$bSuccessUpload = is_uploaded_file($_FILES['Filedata']['tmp_name']);

if ($bSuccessUpload) { //성공 시 파일 사이즈와 URL 전송
 
 $tmp_name = $_FILES['Filedata']['tmp_name'];

 $orig_name = $_FILES['Filedata']['name'];
 $file_ext = get_extension($orig_name);
 
 mt_srand();
 $filename = md5(uniqid(mt_rand())).$file_ext;
 $new_path = $_SERVER['DOCUMENT_ROOT'].'/'.$UPLOAD_DIR.'/'.urlencode($filename);
 
 make_dirs($new_path, TRUE);
 
 if (move_uploaded_file($tmp_name, $new_path)){
  $url .= "&bNewLine=true";
  $url .= "&sFileName=".urlencode(urlencode($orig_name));
  //$url .= "&size=". $_FILES['Filedata']['size'];
  //아래 URL을 변경하시면 됩니다.
  $url .= "&sFileURL=내도메인".$UPLOAD_DIR."/".urlencode(urlencode($filename));
 }else{
  $url .= '&errstr=Upload file move error!!!\n'.$new_path;
 }
} else { //실패시 errstr=error 전송
 $url .= '&errstr=error';
}
header('Location: '. $url);
?>

슈럭 / 2012/07/02 17:01:14 / 추천 0

그리고 이것은 html5의 사용이 가능할 경우 저장되는 페이지입니다.
SmartEditor/popup/quick_photo/FileUploader_html5.php

<?php
function get_extension($filename)
{
 $x = explode('.', $filename);
 return '.'.end($x);
}

function make_dirs($path, $last_is_file=FALSE){

 $dir_arr = explode("/", $path);
 
 if (empty($dir_arr[0])){
  $path = "";
 }elseif($dir_arr[0] == "." || $dir_arr[0] == ".."){
  $path = realpath($dir_arr[0]);
  $dir_arr[0] = "";
 }else{
  $path = "/";
 }

 foreach ($dir_arr as $dir) {
  $dir = trim($dir);
  if (!$dir) continue;

  if ($last_is_file) {
   if ($dir == $dir_arr[count($dir_arr)-1]) {
    return false;
   }
  }

  if (isset($path)) $path .= "/".$dir; else $path = $dir;
  if (@is_dir($path)) continue;

  @mkdir($path, 0707);
  @chmod($path, 0707);

  if(! @copy(VIEW_PATH.'/index.html', $path . '/index.html')){
   $file = $path . "/index.html";
   $f = @fopen($file, "w");
   @fwrite($f, "<html><head><title>403 Forbidden</title></head><body><p>Directory access is forbidden.</p></body></html>");
   @fclose($f);
   @chmod($file, 0606);
  }
 }
}

 $UPLOAD_DIR = 'upload/'.date('Ymd');

  $sFileInfo = '';
 $headers = array();
 foreach ($_SERVER as $k => $v){  
   
  if(substr($k, 0, 9) == "HTTP_FILE"){
   $k = substr(strtolower($k), 5);
   $headers[$k] = $v;
  }
 }

// make_dirs($new_path, TRUE);
 
 $file = new stdClass;
 $file->name = rawurldecode($headers['file_name']); 
 $file->size = $headers['file_size'];
 $file->content = file_get_contents("php://input");

 $orig_name = $file->name;
 $file_ext = get_extension($orig_name);

 mt_srand();
 $filename = md5(uniqid(mt_rand())).$file_ext;
 $newPath = $_SERVER['DOCUMENT_ROOT'].'/'.$UPLOAD_DIR.'/'.$filename;
 
 if(file_put_contents($newPath, $file->content)) {
  $sFileInfo .= "&bNewLine=true";
  $sFileInfo .= "&sFileName=".$file->name;
  $sFileInfo .= "&sFileURL=내도메인/".$UPLOAD_DIR."/".$filename;
 }
 echo $sFileInfo;
 
?>
 

닥스훈트 / 2012/07/04 21:16:11 / 추천 0
 ㄴ 앗.. 뒤늦게 봤네요.. 감사합니다...

정말 좋은 자료가 될 것 같습니다.