-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcontrollers_Ck_upload.php
More file actions
93 lines (79 loc) · 3.45 KB
/
controllers_Ck_upload.php
File metadata and controls
93 lines (79 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ck_upload extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
##############################################################################################################
## Upload form CKeditor
##############################################################################################################
public function upload_ck()
{
ob_get_level();
//Image Save Option
//저장 옵션
$getpath = $this->input->get('path');
$path = 'assets/upload/'.$getpath.'/';
$config['upload_path'] = './'.$path; //YOUR PATH
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '0';
$config['file_name'] = 'file_name';
$config['remove_spaces'] = TRUE;
//Form Upload, Drag & Drop
$CKEditorFuncNum = $this->input->get('CKEditorFuncNum');
if(empty($CKEditorFuncNum))
{
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Drag & Drop
////////////////////////////////////////////////////////////////////////////////////////////////////////
header('Content-Type: application/json');
$this->load->library('upload', $config);
if ( !$this->upload->do_upload("upload"))
{
$jsondata = array('uploaded'=> 0, 'fileName'=> 'null', 'url'=> 'null');
echo json_encode($jsondata);
}
else
{
$data = $this->upload->data();
// JPG compression
if($this->upload->data('file_ext') === '.jpg') {
$filename = $this->upload->data('full_path');
$img = imagecreatefromjpeg($filename);
imagejpeg($img, $filename, 80);
}
$filename = $data['file_name'];
$url = base_url().$path.$filename;
$jsondata = array('uploaded'=> 1, 'fileName'=> $filename, 'url'=> $url);
echo json_encode($jsondata);
}
}
else
{
////////////////////////////////////////////////////////////////////////////////////////////////////////
// Form Upload
////////////////////////////////////////////////////////////////////////////////////////////////////////
$this->load->library('upload', $config);
if ( !$this->upload->do_upload("upload"))
{
echo "<script>alert('Send Fail".$this->upload->display_errors('','')."')</script>";
}
else
{
$CKEditorFuncNum = $this->input->get('CKEditorFuncNum');
$data = $this->upload->data();
// JPG compression
if($this->upload->data('file_ext') === '.jpg') {
$filename = $this->upload->data('full_path');
$img = imagecreatefromjpeg($filename);
imagejpeg($img, $filename, 80);
}
$filename = $data['file_name'];
$url = base_url().$path.$filename;
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction('".$CKEditorFuncNum."', '".$url."', 'Send OK')</script>";
}
}
ob_end_flush();
}
}