<?php
/**
* 添加会员卡
* User: Administrator
* Date: 2019/1/21
* Time: 9:57
*/
$appid=$rs["appid"];
$secret=$rs["secret"];
//获取access_token(每日有获取数量上限,每次获取2小时有效,最好获取后存入数据库2小时内直接调用超时后重新获取)
$TOKEN_URL="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
$json=file_get_contents($TOKEN_URL);
$result=json_decode($json,true);
$ACCESS_TOKEN=$result['access_token'];
//上传图片
$wechat_url = '';
$wechat_backimg = '';
//logo
if(isset($_FILES["file_back"])) {
$uptypes = array(
'image/jpg',
'image/jpeg',
'image/png',
'image/pjpeg',
'image/gif',
'image/bmp',
'image/x-png'
);
$max_file_size = 5000000;
//路劲
$destination2_folder = "../../../img/card_img/";
$imgpreviewsize = 1 / 2;
if (isset($_FILES["file_back"])) {
$file = $_FILES["file_back"];
//print_r($file);
if (!is_uploaded_file($_FILES["file_back"]["tmp_name"])) {
echo "<br/>商户logo不存在!";
} else if ($max_file_size < $file["size"]) {
echo "<br/>商户logo文件太大!";
} else if (!in_array($file["type"], $uptypes)) {
echo "<br/>商户logo文件类型不符!" . $file["type"];
} else {
if (!file_exists($destination2_folder)) {
mkdir($destination2_folder);
}
$filename = $file["tmp_name"];
//print_r($filename);
$image_size = getimagesize($filename);
$pinfo = pathinfo($file["name"]);
// $jqfile = trim(strrchr($pinfo, '/'), '/');
$ftype = $pinfo['extension'];
$destination = $destination2_folder . time() . "two" . "." . $ftype;
//print_r($destination);
//截取文件名称
//$jqfile = trim(strrchr($destination, '/'), '/');
if (file_exists($destination) && $overwrite != true) {
echo "商户logo文件已经存在了";
} else if (!move_uploaded_file($filename, $destination)) {
echo "移动商户logo文件出错";
} else {
//向微信上传图片
$url = "https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token
PHP:微信公众号--创建会员卡
最新推荐文章于 2023-09-26 09:02:24 发布