Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
fenzhan_zsb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esf
fenzhan_zsb
Commits
b3d108b1
Commit
b3d108b1
authored
Aug 17, 2020
by
liuqiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改上传图片方法 zsb/controller/pic.php->house
parent
6507b0a4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletion
+59
-1
zsb_api_model.php
new_admincp/applications/models/zsb_api_model.php
+49
-0
pic.php
new_admincp/applications/zsb/controllers/pic.php
+10
-1
No files found.
new_admincp/applications/models/zsb_api_model.php
View file @
b3d108b1
...
...
@@ -24,6 +24,7 @@ class zsb_api_model extends MY_Model{
'vr_check'
=>
'/zsbapi/broker/vr-add-before'
,
//VR申请校验
'vr_add'
=>
'/zsbapi/broker/vr-add'
,
//VR申请提交
'vr_cancel'
=>
'/zsbapi/broker/vr-cancel'
,
//VR申请取消
'uploadPic'
=>
'/ajax-action/upload-file'
,
// 上传图片接口
);
...
...
@@ -71,6 +72,25 @@ class zsb_api_model extends MY_Model{
return
$response
;
}
/**
* @author Livfer
* @param $key string 接口key
* @param $filename string 文件名
* @param $path string 临时文件路径
* @param string $type string 文件类型
* @return array|bool|mixed|string
*/
public
function
requestFile
(
$key
,
$filename
,
$path
,
$type
=
'text/plain'
)
{
$url
=
$this
->
getApiFullUrl
(
$key
);
$token
=
$this
->
getToken
();
$header
=
array
(
'token:'
.
$token
);
$response
=
$this
->
postUploadFile
(
$url
,
$header
,
$filename
,
$path
,
$type
);
$response
=
json_decode
(
$response
,
true
);
return
$response
;
}
function
httpRequest
(
$sUrl
,
$header
=
array
(),
$aData
=
array
()){
...
...
@@ -88,6 +108,35 @@ class zsb_api_model extends MY_Model{
return
$sResult
;
}
/**
* 上传文件
* @author Livfer
* @param $url string 接口地址
* @param $header array 头
* @param $filename string 上传文件名
* @param $tmpName string 临时文件名
* @param string $type string 文件类型
* @return bool|string
*/
function
postUploadFile
(
$url
,
$header
,
$filename
,
$tmpName
,
$type
=
'text/plain'
)
{
$data
=
array
(
'file_name'
=>
'@'
.
realpath
(
$tmpName
)
.
";type="
.
$type
.
";filename="
.
$filename
,
);
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
true
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$header
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
$response
=
curl_exec
(
$ch
);
if
(
$sError
=
curl_error
(
$ch
)){
return
false
;
}
curl_close
(
$ch
);
return
$response
;
}
public
function
getToken
(){
$uid
=
$this
->
user_arr
[
'uid'
];
...
...
new_admincp/applications/zsb/controllers/pic.php
View file @
b3d108b1
...
...
@@ -40,7 +40,16 @@ class Pic extends MY_Controller {
}***/
$this
->
load
->
model
(
'pic_model'
);
//判断是否上传是360全景图片
$filename
=
$this
->
pic_model
->
get_filename
();
$file
=
$_FILES
[
$filename
];
//文件信息
$filename
=
$file
[
'name'
];
//本地文件名
$tmpFile
=
$file
[
'tmp_name'
];
//临时文件名
$fileType
=
$file
[
'type'
];
//文件类型
$this
->
load
->
model
(
'zsb_api_model'
);
$result
=
$this
->
zsb_api_model
->
requestFile
(
'uploadPic'
,
$filename
,
$tmpFile
,
$fileType
);
return
$result
[
'pic_url'
];
//判断是否上传是360全景图片
if
(
!
empty
(
$_GET
[
'uploadType'
])
&&
$_GET
[
'uploadType'
]
==
'1'
)
{
//360全景图片限制上传大小,默认限制 5M
...
...
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