Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

1.

사전설치

Requirement

2.

이미지 업로드 (동영상, 파일 업로드도 동일

Uploading Image (Same for Uploading Videos and Files)

가이드로 제공되는 아래 코드 중 파일 업로드 부분은 샘플 코드로서 보안 관련 처리가 미흡합니다.

파일 업로드 부분은 프로젝트 내부에서 사용하시는 부분을 그대로 사용하시고 아래 코드를 참고하셔서 연동 부분을 처리해주세요. 
Warning
title주의사항
Caution

Among the following codes provided as the guide, file upload part is a sample and has insufficient security.

As for the file upload, please use the code used within your project and refer the following code to handle the system link.


Code Block
languagephp
themeEmacs
linenumberstrue
<?php
try {
    //업로드Upload 디렉토리directory
    $uploadDir = 'uploads/images';

    //폼 데이터 이름Name of the form data
    $fieldName = 'file';

    //파일File 이름name
    $fileName = explode('.', $_FILES[$fieldName]['name']);

    //파일Filename 확장자extension
    $extension = end($fileName);

    //임시Temporary 파일file 이름name
    $tmpName = $_FILES[$fieldName]['tmp_name'];

    //저장될 새로운 파일이름File name for the new save
    $newFileName = sha1(microtime());

    //실제Actual 파일file 업로드upload 경로path
    $fileUploadPath = "${uploadDir}/${newFileName}.${extension}";

    //파일을Save the 저장합니다file
    move_uploaded_file($tmpName, $fileUploadPath);

    //클라이언트로 응답을 보냅니다Send the response to the client.
    header('Content-Type: application/json');
    echo json_encode(array(
        'uploadPath' => $fileUploadPath,
    ));

} catch (Exception $e) {
    echo $e->getMessage();
    http_response_code(404);
}




3. Importing HWP, MS Word

,

or Excel

문서 임포트

Document

가이드로 제공되는 아래 코드 중 파일 업로드 부분은 샘플 코드로서 보안 관련 처리가 미흡합니다.

파일 업로드 부분은 프로젝트 내부에서 사용하시는 부분을 그대로 사용하시고 아래 코드를 참고하셔서 연동 부분을 처리해주세요. 
Warning
title주의사항
Caution

Among the following codes provided as the guide, file upload part is a sample and has insufficient security.

As for the file upload, please use the code used within your project and refer the following code to handle the system link.


Code Block
languagephp
themeEmacs
linenumberstrue
<?php
try {
    // uploadUpload pathdirectory
    $uploadDir = 'uploads/docs';


    // Name of the form fileddata
name     $fieldName = 'file';

    // fileFile name
    $fileName = explode('.', $_FILES[$fieldName]['name']);

    //fileFilename extension
    $extension = end($fileName);

    // tempTemporary file name
    $tmpName = $_FILES[$fieldName]['tmp_name'];

    // File newname filefor namethe tonew save
    $newFileName = sha1(microtime());

    // Actual file upload path
    $fileUploadPath = "${uploadDir}/${newFileName}.${extension}";

    // saveSave the file
to disk     move_uploaded_file($tmpName, $fileUploadPath);

    // directoryDirectory name to save conversion result
    $wordDir = 'works';

    // executeExecute conversion
    $importPath = "${wordDir}/${newFileName}";
    executeConverter($fileUploadPath, $importPath);

    // serializeSerialize document data
	// Since v2.3.0 부터 파일명이, the file name is changed from document.word.pb에서pb to document.pb로pb
변경됨     $pbFilePath = "${importPath}/document.pb";
    $serializedData = readPBData($pbFilePath);

    // sendSend the response to the client.
    header('Content-Type: application/json');
    echo json_encode(array(
        'serializedData' => $serializedData,
        'importPath' => $importPath,
    ));

} catch (Exception $e) {
    echo $e->getMessage();
    http_response_code(404);
}

function executeConverter($inputFilePath, $outputFilePath)
{
    $sedocConverterPath = 'c:/sedocConverter/sedocConverter.exe';
    $fontsDir = 'c:/sedocConverter/fonts';
    $tempDir = 'c:/sedocConverter/tmp';

    $cmd = "${sedocConverterPath} -f ${fontsDir} ${inputFilePath} ${outputFilePath} ${tempDir}";
    exec($cmd);
}


function readPBData($pbFilePath)
{
    $fb = fopen($pbFilePath, 'r');
    $data = stream_get_contents($fb, -1, 16);
    fclose($fb);

    $byteArray = unpack('C*', zlib_decode($data));
	// php 5.4.0 or 미만below
    // $byteArray = unpack('C*', gzuncompress($data));
    $serializedData = array_values($byteArray);

    return $serializedData;
}





관련정보See also


Children Display
pageIntegration