|
@@ -36,4 +36,44 @@ trait UserTrait
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public function uploadImage($img) {
|
|
|
+ $path = public_path('image');
|
|
|
+ if (!file_exists($path)){
|
|
|
+ mkdir ($path,0777,true);
|
|
|
+ }
|
|
|
+ $fileUrl = $path.date('/Ymd').time().'.jpg';
|
|
|
+ $content = file_get_contents($img);
|
|
|
+ file_put_contents($fileUrl, $content);
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ $url = config("customer.manage_service_url").'/config/upload';
|
|
|
+ $array = [
|
|
|
+ 'multipart' => [
|
|
|
+ [
|
|
|
+ 'name' => 'image',
|
|
|
+ 'contents' => 'data',
|
|
|
+ 'headers' => ['X-Baz' => 'bar'],
|
|
|
+ 'filename' => $fileUrl
|
|
|
+ ]
|
|
|
+ ],
|
|
|
+ 'query' => [],
|
|
|
+ 'http_errors' => false,
|
|
|
+ 'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
|
|
|
+ ];
|
|
|
+ $ossUrl = http($url,$array, false, 'post');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $ossUrl = '';
|
|
|
+ }
|
|
|
+ unlink($fileUrl);
|
|
|
+ return $ossUrl;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function downDown($file_url)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|