1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <?php /\* \*京东图床PHP代码 \*汐岑博客 \*blog.aneu.cn \*/
if (class\_exists('CURLFile')) { // php 5.5 $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\[1\]) { exit('图片上传失败!'); }
$arr = array( 'code' =>200, 'imgurl'=>'https://img'.rand(10,14).'.360buyimg.com/uba/'.$matches\[1\] ); exit(json\_encode($arr)); 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.8"; $httpheader\[\] = "Connection:close"; curl\_setopt($ch, CURLOPT\_HTTPHEADER, $httpheader); if ($post) { curl\_setopt($ch, CURLOPT\_POST, 1); 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==1){ 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/5.0 (Linux; U; Android 4.0.4; es-mx; HTC\_One\_X Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0"); } if ($nobaody) { curl\_setopt($ch, CURLOPT\_NOBODY, 1); } curl\_setopt($ch, CURLOPT\_TIMEOUT, 3); curl\_setopt($ch, CURLOPT\_ENCODING, "gzip"); curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, 1); $ret = curl\_exec($ch); curl\_close($ch); return $ret; }
|