|
@@ -974,22 +974,36 @@ class PatientServies
|
|
|
|
|
|
public function makeUrl($base64_string)
|
|
|
{
|
|
|
- return '';
|
|
|
if(empty($base64_string))
|
|
|
{
|
|
|
return '';
|
|
|
}
|
|
|
+ if(strrpos('http',$base64_string) !== false)
|
|
|
+ {
|
|
|
+ // 传参url
|
|
|
+ $arr = explode('.',$base64_string);
|
|
|
+ $hz = end($arr);
|
|
|
+ $filePath = $_SERVER['DOCUMENT_ROOT'].'/report/'.time().rand(0,9999).'.'.$hz; // 本地文件路径
|
|
|
+ $savePath = $_SERVER['HTTP_HOST'].'/report/'.time().rand(0,9999).'.'.$hz; // 本地文件路径
|
|
|
+ ob_start(); //打开输出
|
|
|
+ readfile($base64_string); //输出图片文件
|
|
|
+ $return = ob_get_contents(); //得到浏览器输出
|
|
|
+ ob_end_clean(); //清除输出并关闭
|
|
|
+ file_put_contents($filePath, $return);
|
|
|
+
|
|
|
+ }else{
|
|
|
// 将Base64字符串分割成数据和文件类型
|
|
|
- list($type, $data) = explode(';', $base64_string);
|
|
|
- list(,$hz) = explode('/',$type);
|
|
|
- list(, $data) = explode(',', $data);
|
|
|
+ list($type, $data) = explode(';', $base64_string);
|
|
|
+ list(,$hz) = explode('/',$type);
|
|
|
+ list(, $data) = explode(',', $data);
|
|
|
// 将Base64解码成二进制数据
|
|
|
- $decodedData = base64_decode($data);
|
|
|
- $filePath = $_SERVER['DOCUMENT_ROOT'].'/report/'.time().rand(0,9999).'.'.$hz; // 本地文件路径
|
|
|
- $savePath = $_SERVER['HTTP_HOST'].'/report/'.time().rand(0,9999).'.'.$hz; // 本地文件路径
|
|
|
+ $decodedData = base64_decode($data);
|
|
|
+ $filePath = $_SERVER['DOCUMENT_ROOT'].'/report/'.time().rand(0,9999).'.'.$hz; // 本地文件路径
|
|
|
+ $savePath = $_SERVER['HTTP_HOST'].'/report/'.time().rand(0,9999).'.'.$hz; // 本地文件路径
|
|
|
|
|
|
// 将数据写入到文件
|
|
|
- file_put_contents($filePath, $decodedData);
|
|
|
+ file_put_contents($filePath, $decodedData);
|
|
|
+ }
|
|
|
return $savePath;
|
|
|
}
|
|
|
|