| Table of Contents |
|---|
1.
사전설치Requirement
- PHP ZipArchive (http://php.net/manual/en/class.ziparchive.php)
2.
이미지 업로드 (동영상, 파일 업로드도 동일Uploading Image (Same for Uploading Videos and Files)
| Warning | ||||
|---|---|---|---|---|
|
| |||
Among the following codes provided as the guide, file upload part is a sample code 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 | ||||||
|---|---|---|---|---|---|---|
| ||||||
<?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
,and Excel
문서 임포트Documents
| Warning | ||||
|---|---|---|---|---|
|
| |||
Among the following codes provided as the guide, file upload part is a sample code 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 | ||||||
|---|---|---|---|---|---|---|
| ||||||
<?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 | ||
|---|---|---|
|