上传时检测是否图片php,php检测小程序上传图片是否违规

/**

* @Apidoc\Title("上传图片")

* @Apidoc\Desc("上传图片")

* @Apidoc\Url("/index/uploadpic")

* @Apidoc\Method("get")

* @Apidoc\Tag("")

* @Apidoc\Header("")

* @Apidoc\Param("filename", type="string",require=true, desc="上传图片的file名称" )

* @Apidoc\Returned("", type="", desc="图片路径")

*/

public function uploadpic()

{

$pic_path = $this->one_upload('filename');

return $pic_path;

}

/**

* @Apidoc\Title("图片检测")

* @Apidoc\Desc("图片检测")

* @Apidoc\Url("/index/imagecheck")

* @Apidoc\Method("get")

* @Apidoc\Tag("")

* @Apidoc\Header("")

* @Apidoc\Param("picpath", type="string",require=true, desc="uploadpic返回的图片路径" )

* @Apidoc\Returned("", type="", desc="")

*/

public function imagecheck()

{

$picpath=input('picpath','');

if(empty($picpath)){ $this->BackResult(1, '请传入图片'); }

$access_token=weixin_access_token_check();

//图片检测

$result=$this->imagecheckcall($access_token,$picpath);

// echo '

';

// print_r($result);

$this->BackResult(0, '数据结果',$result);

}

//图片检测

public function imagecheckcall($access_token='',$img_path)

{

$img_path='./'.$img_path;

$url='https://api.weixin.qq.com/wxa/img_sec_check?access_token='.$access_token;

if (class_exists('\CURLFile')) {

$josn = array('media' => new \CURLFile(realpath($img_path)));

} else {

$josn = array('media' => '@' . realpath($img_path));

}

$result=curl_call($url,'post',$josn);

$result=json_decode($result,true);

//print_r($result);

return $result;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值