{"action":"closed","issue":{"url":"https://api.github.com/repos/whh306318848/PHPToQyWeixin/issues/3","repository_url":"https://api.github.com/repos/whh306318848/PHPToQyWeixin","labels_url":"https://api.github.com/repos/whh306318848/PHPToQyWeixin/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/whh306318848/PHPToQyWeixin/issues/3/comments","events_url":"https://api.github.com/repos/whh306318848/PHPToQyWeixin/issues/3/events","html_url":"https://github.com/whh306318848/PHPToQyWeixin/issues/3","id":139774144,"number":3,"title":"PHP5.6后上传图片有问题","user":{"login":"hel2o","id":14226648,"avatar_url":"https://avatars.githubusercontent.com/u/14226648?v=3","gravatar_id":"","url":"https://api.github.com/users/hel2o","html_url":"https://github.com/hel2o","followers_url":"https://api.github.com/users/hel2o/followers","following_url":"https://api.github.com/users/hel2o/following{/other_user}","gists_url":"https://api.github.com/users/hel2o/gists{/gist_id}","starred_url":"https://api.github.com/users/hel2o/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hel2o/subscriptions","organizations_url":"https://api.github.com/users/hel2o/orgs","repos_url":"https://api.github.com/users/hel2o/repos","events_url":"https://api.github.com/users/hel2o/events{/privacy}","received_events_url":"https://api.github.com/users/hel2o/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-10T03:37:05Z","updated_at":"2016-03-11T13:16:00Z","closed_at":"2016-03-11T13:16:00Z","body":"升级PHP5.6版本后上传图片报\r\n```\r\nArray\r\n(\r\n    [errcode] => 41005\r\n    [errmsg] => media data missing\r\n    [success] => \r\n)\r\n```\r\n报错的原因是PHP5.6后对curl_setopt做了改动\r\n解决办法：\r\n在`curl_init();`之后添加`curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);` 且要加在`curl_setopt($ch, CURLOPT_POSTFIELDS, $data);`**之前**\r\n完整如下\r\n   ```\r\n     public function uploadFileByPost($url, $data) {\r\n                $ch = curl_init();\r\n                curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);\r\n                curl_setopt($ch, CURLOPT_URL, $url);\r\n                curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);\r\n                curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);\r\n                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);\r\n                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);\r\n                curl_setopt($ch, CURLOPT_POST, TRUE);\r\n                curl_setopt($ch, CURLOPT_POSTFIELDS, $data);\r\n                $result = curl_exec($ch);\r\n                if ($error = curl_error($ch)) {\r\n                        die($error);\r\n                }\r\n                curl_close($ch);\r\n\r\n                return json_decode($result, TRUE);\r\n        }\r\n```"}}