标签:timeout not highlight cep 上传 问题 throw mis time
问题描述:
php5.5已经把通过@加文件路径上传文件的方式给放入到Deprecated中了。php5.6默认是不支持这种方式了
解决办法curl处理
function curl_post($url, $data, $header = array()){ if(function_exists(‘curl_init‘)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); if(is_array($header) && !empty($header)){ $set_head = array(); foreach ($header as $k=>$v){ $set_head[] = "$k:$v"; } curl_setopt($ch, CURLOPT_HTTPHEADER, $set_head); } curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 0);// 1s to timeout. $response = curl_exec($ch); if(curl_errno($ch)){ //error return curl_error($ch); } $reslut = curl_getinfo($ch); print_r($reslut); curl_close($ch); $info = array(); if($response){ $info = json_decode($response, true); } return $info; } else { throw new Exception(‘Do not support CURL function.‘); } }
$file = "a.jpg"; $data = array( ‘media‘=> new CURLFile($file) ); $result = $this->curl_post(self::WEIXIN_API . ‘media/upload?access_token=‘ . $this->get_access_token($app_id, $app_secret) . ‘&type=‘ . $type ,$data);
微信上传素材返回 '{"errcode":41005,"errmsg":"media data missing"}',php5.6返回
标签:timeout not highlight cep 上传 问题 throw mis time
原文地址:http://www.cnblogs.com/padog/p/6150516.html