vhost init...2
This commit is contained in:
parent
fa0034403c
commit
92929fa5d7
@ -1,6 +1,6 @@
|
||||
<!-- left menu start -->
|
||||
<link href="/css/admin/left_menu.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/side_menu.js"></script>
|
||||
<script type="text/javascript" src="/js/admin/side_menu.js"></script>
|
||||
<div id="left_menu" class="shadow-lg rounded">
|
||||
<div class="accordion accordion-flush">
|
||||
<?= $this->include($viewDatas['layout']['path'] . '/left_menu/base'); ?>
|
||||
|
||||
@ -25,12 +25,40 @@
|
||||
$(".select-field").select2({
|
||||
theme: "bootstrap-5",
|
||||
});
|
||||
//class가 editor인 textarea용
|
||||
// text editor 초기화
|
||||
//참고: https://phppot.com/menu/php/learn-php/
|
||||
// class가 editor인 textarea용
|
||||
tinymce.init({
|
||||
selector: 'textarea.editor',
|
||||
plugins: 'code',
|
||||
plugins: ['code', 'image'],
|
||||
toolbar: 'image',
|
||||
height: 600,
|
||||
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }'
|
||||
// content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }'
|
||||
automatic_uploads: false,
|
||||
images_upload_url: '/tinymce_upload.php',
|
||||
// images_upload_base_path: '/upload_images',
|
||||
images_upload_handler: function(blobInfo, success, failure) {
|
||||
var xhr, formData;
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.withCredentials = false;
|
||||
xhr.open('POST', '/tinymce_upload.php');
|
||||
xhr.onload = function() {
|
||||
var json;
|
||||
if (xhr.status != 200) {
|
||||
failure('HTTP Error: ' + xhr.status);
|
||||
return;
|
||||
}
|
||||
json = JSON.parse(xhr.responseText);
|
||||
if (!json || typeof json.file_path != 'string') {
|
||||
failure('Invalid JSON: ' + xhr.responseText);
|
||||
return;
|
||||
}
|
||||
success(json.file_path);
|
||||
};
|
||||
formData = new FormData();
|
||||
formData.append('file', blobInfo.blob(), blobInfo.filename());
|
||||
xhr.send(formData);
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -12,7 +12,7 @@
|
||||
"twbs/bootstrap": "5.2.3",
|
||||
"guzzlehttp/guzzle": "^7.7",
|
||||
"google/apiclient": "2.12.1",
|
||||
"tinymce/tinymce": "^6.6"
|
||||
"tinymce/tinymce": "^7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.9",
|
||||
|
||||
32
public/tinymce_upload.php
Normal file
32
public/tinymce_upload.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
$url = array(
|
||||
"http://localhost"
|
||||
);
|
||||
|
||||
reset($_FILES);
|
||||
$temp = current($_FILES);
|
||||
|
||||
if (is_uploaded_file($temp['tmp_name'])) {
|
||||
if (preg_match("/([^\w\s\d\-_~,;:\[\]\(\).])|([\.]{2,})/", $temp['name'])) {
|
||||
header("HTTP/1.1 400 Invalid file name,Bad request");
|
||||
return;
|
||||
}
|
||||
|
||||
// Validating File extensions
|
||||
if (!in_array(strtolower(pathinfo($temp['name'], PATHINFO_EXTENSION)), array(
|
||||
"gif",
|
||||
"jpg",
|
||||
"png"
|
||||
))) {
|
||||
header("HTTP/1.1 400 Not an Image");
|
||||
return;
|
||||
}
|
||||
|
||||
$fileName = "tinymce_uploads/" . $temp['name'];
|
||||
move_uploaded_file($temp['tmp_name'], $fileName);
|
||||
|
||||
// Return JSON response with the uploaded file path.
|
||||
echo json_encode(array(
|
||||
'file_path' => $fileName
|
||||
));
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user