...
|
...
|
@@ -59,22 +59,15 @@ class MemberController extends CommentController |
|
|
public function upload_wx_pic(){
|
|
|
$access_token = $this->getAccessToken();
|
|
|
$img_str = $this->request->param('media','','string');
|
|
|
$a['g'] = json_encode($img_str);
|
|
|
$img_arr = explode(',',rtrim($img_str,','));
|
|
|
$foldername = 'pic/'.date('Ymd');
|
|
|
$imgurls = '';
|
|
|
$a['d'] = $access_token;
|
|
|
foreach($img_arr as $v) {
|
|
|
$url = $this->getmedia($access_token,$v,$foldername);
|
|
|
$imgurls .= ','. $url;
|
|
|
}
|
|
|
$data['imgurls'] = ltrim($imgurls,',');
|
|
|
$data['httpimgurls'] = cmf_get_image_preview_url($data['imgurls']);
|
|
|
|
|
|
$a['a'] = '33333';
|
|
|
$a['e'] = json_encode($imgurls);
|
|
|
$a['f'] = $data['httpimgurls'];
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$this->apiResponse(1,'上传成功',$data);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -87,12 +80,18 @@ class MemberController extends CommentController |
|
|
*/
|
|
|
private function getmedia($access_token,$media_id,$foldername){
|
|
|
$url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=".$access_token."&media_id=".$media_id;
|
|
|
|
|
|
$a['a'] = '4444';
|
|
|
$a['e'] = json_encode($url);
|
|
|
|
|
|
if (!file_exists("./upload/".$foldername)) {
|
|
|
mkdir("./upload/".$foldername, 0777, true);
|
|
|
}
|
|
|
$file_name=date('YmdHis').rand(1000,9999).'.jpg';
|
|
|
$targetName = './upload/'.$foldername.'/'.$file_name;
|
|
|
$saveName = $foldername.'/'.$file_name;
|
|
|
$a['f'] = $saveName;
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$ch = curl_init($url); // 初始化
|
|
|
$fp = fopen($targetName, 'wb'); // 打开写入
|
|
|
curl_setopt($ch, CURLOPT_FILE, $fp); // 设置输出文件的位置,值是一个资源类型
|
...
|
...
|
|