You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
853 B
34 lines
853 B
8 months ago
|
<?php
|
||
|
/**
|
||
|
* 苏宁开放平台接口 - 上传业务类
|
||
|
*
|
||
|
* @author jerry(14033184@cnsuning.com)
|
||
|
* @date 2014-05-29
|
||
|
*/
|
||
|
|
||
|
class SuningUploadRequest
|
||
|
{
|
||
|
/**
|
||
|
* 获取图片的二进制流并base64
|
||
|
*
|
||
|
* $param string $filaName 表单名称(input type=file的name值)
|
||
|
* $return string
|
||
|
*/
|
||
|
public static function getPicStreamByBase64($fileName)
|
||
|
{
|
||
|
// 检查图片扩展名
|
||
|
$ext = strtolower(str_replace('image/', '', $_FILES[$fileName]['type']));
|
||
|
RequestCheckUtil::checkPicExt($ext);
|
||
|
|
||
|
$ctx = stream_context_create(
|
||
|
array(
|
||
|
'http' => array(
|
||
|
'timeout' => 2, // 设置超时
|
||
|
)
|
||
|
)
|
||
|
);
|
||
|
$file = file_get_contents($_FILES[$fileName]['tmp_name'], false, $ctx);
|
||
|
return base64_encode($file);
|
||
|
}
|
||
|
}
|
||
|
?>
|