|
@@ -915,6 +915,13 @@ if (!function_exists('get_image_path')) {
|
|
|
if (empty($image_url)) {
|
|
if (empty($image_url)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 是否七牛
|
|
|
|
|
+ $driver = \App\Services\ConfigService::make()->getConfigByCode('file_upload_driver','local');
|
|
|
|
|
+ if($driver == 'qiniu'){
|
|
|
|
|
+ return $image_url;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$data = explode('/uploads', $image_url);
|
|
$data = explode('/uploads', $image_url);
|
|
|
return $data ? end($data) : $image_url;
|
|
return $data ? end($data) : $image_url;
|
|
|
}
|
|
}
|
|
@@ -1041,17 +1048,21 @@ if (!function_exists('get_format_content')) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$domain = request()->header('HOST');
|
|
$domain = request()->header('HOST');
|
|
|
|
|
+ $driver = \App\Services\ConfigService::make()->getConfigByCode('file_upload_driver','local');
|
|
|
if(preg_match("/127/", $domain)){
|
|
if(preg_match("/127/", $domain)){
|
|
|
$host = env('IMG_URL','');
|
|
$host = env('IMG_URL','');
|
|
|
if(empty($host)){
|
|
if(empty($host)){
|
|
|
$https = request()->secure();
|
|
$https = request()->secure();
|
|
|
$host = ($https ? 'https://' : 'http://') . $host . '/uploads';
|
|
$host = ($https ? 'https://' : 'http://') . $host . '/uploads';
|
|
|
}
|
|
}
|
|
|
|
|
+ }else if($driver == 'qiniu'){
|
|
|
|
|
+ $host = \App\Services\ConfigService::make()->getConfigByCode('qiniu_host','');
|
|
|
}else{
|
|
}else{
|
|
|
$https = request()->secure();
|
|
$https = request()->secure();
|
|
|
$host = ($https ? 'https://' : 'http://') . $domain . '/uploads';
|
|
$host = ($https ? 'https://' : 'http://') . $domain . '/uploads';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
$content = str_replace(["\"/uploads","'/uploads"],["\"{$host}","'{$host}"], htmlspecialchars_decode($content));
|
|
$content = str_replace(["\"/uploads","'/uploads"],["\"{$host}","'{$host}"], htmlspecialchars_decode($content));
|
|
|
return $content;
|
|
return $content;
|
|
|
}
|
|
}
|
|
@@ -1885,11 +1896,20 @@ if (!function_exists('upload_image')) {
|
|
|
$file_name = ($userId? $userId.'_'.str_replace('=','',base64_encode(date('YmdHis').$userId.$original_name)): str_replace('=','',base64_encode(date('YmdHis').$original_name)));
|
|
$file_name = ($userId? $userId.'_'.str_replace('=','',base64_encode(date('YmdHis').$userId.$original_name)): str_replace('=','',base64_encode(date('YmdHis').$original_name)));
|
|
|
$file_name = $file_name. '.' . $ext;
|
|
$file_name = $file_name. '.' . $ext;
|
|
|
|
|
|
|
|
- // 重命名保存
|
|
|
|
|
- $path = $file->move($file_dir, $file_name);
|
|
|
|
|
|
|
+ $driver = \App\Services\ConfigService::make()->getConfigByCode('file_upload_driver','local');
|
|
|
|
|
+ if($driver == 'qiniu'){
|
|
|
|
|
+ // 上传云
|
|
|
|
|
+ $file_path = \App\Services\QiniuService::make()->upload($file_name, $file);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 重命名保存
|
|
|
|
|
+ $path = $file->move($file_dir, $file_name);
|
|
|
|
|
+ // 文件临时路径
|
|
|
|
|
+ $file_path = str_replace(ATTACHMENT_PATH, '', $file_dir) . '/' . $file_name;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- // 文件临时路径
|
|
|
|
|
- $file_path = str_replace(ATTACHMENT_PATH, '', $file_dir) . '/' . $file_name;
|
|
|
|
|
|
|
|
|
|
// 返回结果
|
|
// 返回结果
|
|
|
$result = [
|
|
$result = [
|