資源簡介
微信上傳圖片接口之保存圖片,也可保存其他下載圖片地址的圖片
代碼片段和文件信息
public?function?uploadpic(){
error_reporting(0);
$serverId =?I(‘serverId‘);
$access_token =?wechatauth_v1::getInstance()->getAccessToken();
$img_wxurl?=?‘http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=‘
.$access_token.‘&media_id=‘.$serverId;
$times =?time();
$rootpath =?$_SERVER[‘DOCUMENT_ROOT‘].‘/‘;
$dirname =?‘Uploads/wx_pic/‘.date(‘Ymd‘).‘/‘;
$this->dir_create($rootpath.$dirname);
$imgname =?‘wx_plus_‘.$times.‘.jpg‘;
$thumb_imgname =?‘wx_plus_240_‘.$times.‘.jpg‘;
$img_url =?C(‘SITE_URL‘).$dirname.$imgname;
$thumb_img_url =?C(‘SITE_URL‘).$dirname.$thumb_imgname;
$imgpath =?$rootpath.$dirname.$imgname;
copy($img_wxurl$imgpath);
$image?=?new?\Think\Image();
$image->open($imgpath);
$image->thumb(240?240)->save($rootpath.$
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6156??2016-04-18?10:33??index.html
?????文件???????1323??2016-04-16?17:23??i.php
-----------?---------??----------?-----??----
?????????????????7479????????????????????2
- 上一篇:計算機操作系統期末考試題及答案
- 下一篇:批量將圖片轉化成灰度圖并保存
評論
共有 條評論