Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
1f6569af98c7f5ae07e352dbc67ea137211e37bd
1 parent
18845d11
修复意见反馈图片上传接接口的问题
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
52 deletions
library/Plugin/Images.php
yohobuy/m.yohobuy.com/application/controllers/Home.php
yohobuy/m.yohobuy.com/application/models/Index/User.php
library/Plugin/Images.php
View file @
1f6569a
...
...
@@ -133,14 +133,8 @@ class Images
{
$images
[
$files
[
'name'
]]
=
$files
[
'tmp_name'
];
}
if
(
$_SERVER
[
'HTTP_HOST'
]
!=
'test.service.api.yohobuy.com'
)
//代理转接
{
return
self
::
agentCurlImage
(
$images
);
}
else
{
return
self
::
uploadStreamImage
(
$images
);
}
return
self
::
uploadStreamImage
(
$images
);
}
/**
...
...
@@ -199,43 +193,6 @@ class Images
}
}
/**
* 代理上传图片
*
* @param array|string $files
* @return array
*/
private
static
function
agentCurlImage
(
$file
)
{
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
0
);
curl_setopt
(
$ch
,
CURLOPT_VERBOSE
,
0
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$ch
,
CURLOPT_USERAGENT
,
"Mozilla/4.0 (compatible;)"
);
curl_setopt
(
$ch
,
CURLOPT_URL
,
'http://test.service.api.yohobuy.com/sns/ajax/uploadimg'
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
true
);
$params
=
array
();
$files
=
is_array
(
$file
)
?
$file
:
array
(
$file
);
foreach
(
$files
as
$key
=>
$name
)
{
$key
=
is_numeric
(
$key
)
?
$key
.
'.jpg'
:
$key
;
$filename
=
dirname
(
$name
)
.
'/'
.
$key
;
rename
(
$name
,
$filename
);
if
(
@
class_exists
(
'\CURLFile'
))
{
$params
[
"images[
$key
]"
]
=
new
\CURLFile
(
realpath
(
$filename
));
}
else
{
$params
[
"images[
$key
]"
]
=
'@'
.
realpath
(
$filename
);
}
}
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$params
);
$response
=
json_decode
(
curl_exec
(
$ch
),
true
);
return
$response
[
'data'
];
}
/**
* 获取模板的图片地址
* @param $fileName
...
...
yohobuy/m.yohobuy.com/application/controllers/Home.php
View file @
1f6569a
...
...
@@ -370,7 +370,8 @@ class HomeController extends AbstractAction
/**
* 意见反馈-提交表单页面
*/
public
function
suggestSubAction
()
{
public
function
suggestSubAction
()
{
// 设置网站标题
$this
->
setTitle
(
'反馈问题'
);
...
...
@@ -398,13 +399,12 @@ class HomeController extends AbstractAction
/**
* 异步上传图片
*/
public
function
suggestimgUploadAction
()
{
if
(
$this
->
isAjax
())
{
$filename
=
$this
->
get
(
'filename'
,
''
);
$result
=
\Plugin\Images
::
saveImage
(
$filename
);
public
function
suggestimgUploadAction
()
{
$filename
=
$this
->
post
(
'filename'
,
''
);
$result
=
\Index\UserModel
::
saveSuggestImg
(
$filename
);
$this
->
echoJson
(
$result
);
}
$this
->
echoJson
(
$result
);
}
/**
...
...
yohobuy/m.yohobuy.com/application/models/Index/User.php
View file @
1f6569a
...
...
@@ -370,6 +370,25 @@ class UserModel
}
/**
* 图片上传
*
* @return array|mixed 保存意见反馈数据之后的返回
*/
public
static
function
saveSuggestImg
(
$filename
)
{
$result
=
array
();
if
(
!
isset
(
$_FILES
[
$filename
]))
{
$result
[
'code'
]
=
400
;
$result
[
'message'
]
=
'文件上传错误'
;
}
else
{
$result
=
Images
::
saveImage
(
$filename
);
}
return
$result
;
}
/**
* 保存意见反馈数据
*
* @param int $uid 用户ID
...
...
Please
register
or
login
to post a comment