Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李洋
/
消息系统
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
82458740
authored
Nov 09, 2018
by
李洋
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
替换ueditor的PHP文件夹
parent
c1e41f57
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
14 deletions
public/js/Message/editor/php/Uploader.class.php
public/js/Message/editor/php/action_crawler.php
public/js/Message/editor/php/action_upload.php
public/js/Message/editor/php/Uploader.class.php
View file @
82458740
<?php
<?php
use
OSS\OssClient
;
// OSS客户端类
use
OSS\Core\OssException
;
// OSS异常类
$path
=
preg_replace
(
'/public/'
,
''
,
$_SERVER
[
'DOCUMENT_ROOT'
]);
require_once
$path
.
'/vendor/OSS/autoload.php'
;
/**
/**
* Created by JetBrains PhpStorm.
* Created by JetBrains PhpStorm.
...
@@ -107,19 +113,80 @@ class Uploader
...
@@ -107,19 +113,80 @@ class Uploader
}
}
//创建目录失败
//创建目录失败
if
(
!
file_exists
(
$dirname
)
&&
!
mkdir
(
$dirname
,
0777
,
true
))
{
// if (!file_exists($dirname) && !mkdir($dirname, 0777, true)) {
$this
->
stateInfo
=
$this
->
getStateInfo
(
"ERROR_CREATE_DIR"
);
// $this->stateInfo = $this->getStateInfo("ERROR_CREATE_DIR");
return
;
// return;
}
else
if
(
!
is_writeable
(
$dirname
))
{
// } else if (!is_writeable($dirname)) {
$this
->
stateInfo
=
$this
->
getStateInfo
(
"ERROR_DIR_NOT_WRITEABLE"
);
// $this->stateInfo = $this->getStateInfo("ERROR_DIR_NOT_WRITEABLE");
return
;
// return;
// }
// 上传到OSS
$accessKeyId
=
'LTAIEIrl7ZgNVagi'
;
$accessKeySecret
=
'I14efjgfLXpWtHhfdDO77LrFkeSkPA'
;
$endPoint
=
'http://oss-cn-shenzhen.aliyuncs.com'
;
$bucket
=
'ichunt-img'
;
$ossClient
=
new
OssClient
(
$accessKeyId
,
$accessKeySecret
,
$endPoint
);
$fileType
=
$this
->
fileType
(
$file
[
'type'
]);
$object
=
$fileType
.
'/cms/'
.
$this
->
fullName
;
$result
=
$ossClient
->
uploadFile
(
$bucket
,
$object
,
$file
[
"tmp_name"
]);
// 上传返回
if
(
isset
(
$result
)
&&
$result
[
'info'
][
'http_code'
]
==
200
)
{
$this
->
stateInfo
=
$this
->
stateMap
[
0
];
}
else
{
$this
->
stateInfo
=
$this
->
getStateInfo
(
"ERROR_FILE_MOVE"
);
}
}
//移动文件
//移动文件
if
(
!
(
move_uploaded_file
(
$file
[
"tmp_name"
],
$this
->
filePath
)
&&
file_exists
(
$this
->
filePath
)))
{
//移动失败
// if (!(move_uploaded_file($file["tmp_name"], $this->filePath) && file_exists($this->filePath))) { //移动失败
$this
->
stateInfo
=
$this
->
getStateInfo
(
"ERROR_FILE_MOVE"
);
// $this->stateInfo = $this->getStateInfo("ERROR_FILE_MOVE");
}
else
{
//移动成功
// } else { //移动成功
$this
->
stateInfo
=
$this
->
stateMap
[
0
];
// $this->stateInfo = $this->stateMap[0];
// }
}
/**
* 文件类型
* @param [String] $fileType [MIME]
* @return [String]
*/
public
function
fileType
(
$fileType
)
{
switch
(
$fileType
)
{
case
'image/jpeg'
:
case
'image/png'
:
case
'image/gif'
:
case
'image/bmp'
:
return
'images'
;
break
;
case
'application/msword'
:
return
'documet'
;
break
;
case
'application/vnd.ms-excel'
:
return
'excel'
;
break
;
case
'application/vnd.ms-powerpoint'
:
return
'ppt'
;
break
;
case
'application/pdf'
:
return
'pdf'
;
break
;
case
'text/plain'
;
return
'txt'
;
break
;
case
'video/avi'
:
case
'application/vnd.rn-realmedia-vbr'
:
// case 'application/octet-stream':
return
'video'
;
break
;
default
:
return
$this
->
_json
(
403
,
'暂时不支持此文件类型上传'
);
break
;
}
}
}
}
...
@@ -341,8 +408,10 @@ class Uploader
...
@@ -341,8 +408,10 @@ class Uploader
public
function
getFileInfo
()
public
function
getFileInfo
()
{
{
//分配正确路径
//分配正确路径
$urlroot
=
explode
(
'Public/plugin/editor/php'
,
$_SERVER
[
'PHP_SELF'
]);
// $urlroot = explode('Public/plugin/editor/php', $_SERVER['PHP_SELF']);
$urlroot
=
$urlroot
[
0
]
.
'Uploads/'
;
// $urlroot = $urlroot[0] . 'Uploads/';
$urlroot
=
'http://img.ichunt.com/images/cms/'
;
return
array
(
return
array
(
"state"
=>
$this
->
stateInfo
,
"state"
=>
$this
->
stateInfo
,
...
...
public/js/Message/editor/php/action_crawler.php
View file @
82458740
...
@@ -25,8 +25,13 @@ if (isset($_POST[$fieldName])) {
...
@@ -25,8 +25,13 @@ if (isset($_POST[$fieldName])) {
$source
=
$_GET
[
$fieldName
];
$source
=
$_GET
[
$fieldName
];
}
}
foreach
(
$source
as
$imgUrl
)
{
foreach
(
$source
as
$imgUrl
)
{
$item
=
new
Uploader
(
$imgUrl
,
$config
,
"remote"
);
if
(
strstr
(
$imgUrl
,
'img.ichunt.com'
)
===
FALSE
){
$info
=
$item
->
getFileInfo
();
$item
=
new
Uploader
(
$imgUrl
,
$config
,
"remote"
);
$info
=
$item
->
getFileInfo
();
}
else
$info
=
[
'state'
=>
'SUCCESS'
,
'url'
=>
$imgUrl
];
array_push
(
$list
,
array
(
array_push
(
$list
,
array
(
"state"
=>
$info
[
"state"
],
"state"
=>
$info
[
"state"
],
"url"
=>
$info
[
"url"
],
"url"
=>
$info
[
"url"
],
...
...
public/js/Message/editor/php/action_upload.php
View file @
82458740
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
* Date: 14-04-09
* Date: 14-04-09
* Time: 上午10:17
* Time: 上午10:17
*/
*/
include
"Uploader.class.php"
;
include
"Uploader.class.php"
;
/* 上传配置 */
/* 上传配置 */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment