| Table of Contents |
|---|
1.
Installing JSON Encoder
설치다운로드 Download : JSON.phps
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
//업로드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);
// Include JSON Encoder를 include 한다Encoder.
include("./JSON.phps");
//클라이언트로 응답을 보냅니다Send the response to the client.
header('Content-Type: application/json');
echo json_encode_new(array(
'uploadPath' => $fileUploadPath,
));
function json_encode_new($data) {
$json = new Services_JSON();
return($json->encode($data));
}
?>
|
3. Importing HWP, MS Word
, LibreOffice 문서 임포트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
// uploadUpload pathdirectory
$uploadDir = 'uploads/docs';
// Name of the form filed namedata
$fieldName = 'file';
// fileFile name
$fileName = explode('.', $_FILES[$fieldName]['name']);
//fileFilename extension
$extension = end($fileName);
// tempTemporary file name
$tmpName = $_FILES[$fieldName]['tmp_name'];
// newFile name 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);
include("./JSON.phps");
// sendSend the response to the client.
header('Content-Type: application/json');
echo json_encode_new(array(
'serializedData' => $serializedData,
'importPath' => $importPath,
));
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)
{
$filesize = filesize($pbFilePath);
$zd = gzopen($pbFilePath, "r");
$data = substr( gzread($zd, $filesize), 16 );
gzclose($zd);
$byteArray = unpack('C*', gzuncompress($data));
$serializedData = array_values($byteArray);
return $serializedData;
}
function json_encode_new($data) {
$json = new Service_JSON();
return($json->encode($data));
}
?> |
관련정보See also
| Children Display | ||
|---|---|---|
|