...
|
...
|
@@ -133,14 +133,8 @@ class Images |
|
|
{
|
|
|
$images[$files['name']] = $files['tmp_name'];
|
|
|
}
|
|
|
if($_SERVER['HTTP_HOST'] != 'test.service.api.yohobuy.com') //代理转接
|
|
|
{
|
|
|
return self::agentCurlImage($images);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return self::uploadStreamImage($images);
|
|
|
}
|
|
|
|
|
|
return self::uploadStreamImage($images);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -199,43 +193,6 @@ class Images |
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 代理上传图片
|
|
|
*
|
|
|
* @param array|string $files
|
|
|
* @return array
|
|
|
*/
|
|
|
private static function agentCurlImage($file)
|
|
|
{
|
|
|
$ch = curl_init();
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
|
|
|
curl_setopt($ch, CURLOPT_URL, 'http://test.service.api.yohobuy.com/sns/ajax/uploadimg');
|
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
|
$params = array();
|
|
|
$files = is_array($file) ? $file : array($file);
|
|
|
foreach($files as $key => $name)
|
|
|
{
|
|
|
$key = is_numeric($key) ? $key.'.jpg' : $key;
|
|
|
$filename = dirname($name).'/'.$key;
|
|
|
rename($name, $filename);
|
|
|
if (@class_exists('\CURLFile'))
|
|
|
{
|
|
|
$params["images[$key]"] = new \CURLFile(realpath($filename));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
$params["images[$key]"] = '@' . realpath($filename);
|
|
|
}
|
|
|
}
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
|
|
$response = json_decode(curl_exec($ch), true);
|
|
|
return $response['data'];
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取模板的图片地址
|
|
|
* @param $fileName
|
...
|
...
|
|