<必修php
header("Content-type:text/html;charset=utf- 八");
//jkch.net
if (class_exists('CURLFile')) { // php 五. 五
$post['file'] = new \CURLFile(realpath($_FILES['Filedata']['tmp_name']));
} else {
$post['file'] = '@'.realpath($_FILES['Filedata']['tmp_name']);
}
$rel = get_curl('https://search.jd.com/image必修op=upload',$post);
preg_match('/callback(必修:\(\")(.*)(必修:\"\))/i',$rel,$matches);
if (!$matches[ 一]) {
exit('图片上传掉 败!');
}
$arr = array(
'code' => 二00,
'imgurl'=> 'https://img'.rand( 一0, 一 四).'. 三 六0buyimg.com/uba/'.$matches[ 一]
);
$jsondata = json_encode($arr);
$obj = json_decode($jsondata);
$imgurl = $obj->imgurl;
echo "小桃子事情 室"."<br/>";
echo "图片上传胜利 "."<br/>";
echo "图片天址:".$imgurl."<br/>";
echo "<img src=\"".$imgurl."\"/>"."<br/>";
echo "json:".json_encode($arr);
exit();
function get_curl($url, $post=0, $referer=0, $cookie=0, $header=0, $ua=0, $nobaody=0){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:application/json";
$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0. 八";
$httpheader[] = "Connection:close";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if ($post) {
curl_setopt($ch, CURLOPT_POST, 一);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if ($header) {
curl_setopt($ch, CURLOPT_HEADER, true);
}
if ($cookie) {
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if($referer){
if($referer== 一){
curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter必修g_f=');
}else{
curl_setopt($ch, CURLOPT_REFERER, $referer);
}
}
if ($ua) {
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
}
else {
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/ 五.0 (Linux; U; Android 四.0. 四; es-mx; HTC_One_X Build/IMM 七 六D) AppleWebKit/ 五 三 四. 三0 (KHTML, like Gecko) Version/ 四.0");
}
if ($nobaody) {
curl_setopt($ch, CURLOPT_NOBODY, 一);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 三);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 一);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}