|
@@ -99,7 +99,7 @@ class FileUploadService extends Service
|
|
|
}
|
|
|
|
|
|
public function createOssUpload($file){
|
|
|
- if(! is_array($file) && empty($file)) return;
|
|
|
+ if(! is_array($file) || empty($file)) return;
|
|
|
foreach ($file as $filename){
|
|
|
$filename = str_replace(FileUploadService::string.FileUploadService::string2,'', $filename);
|
|
|
$timestamp = substr($filename, 0, 8); // 截取前八位数字
|
|
@@ -114,7 +114,7 @@ class FileUploadService extends Service
|
|
|
}
|
|
|
|
|
|
public function createOssUploadOld($file){
|
|
|
- if(! is_array($file) && empty($file)) return;
|
|
|
+ if(! is_array($file) || empty($file)) return;
|
|
|
|
|
|
foreach ($file as $filename){
|
|
|
if(strpos($filename, FileUploadService::string.FileUploadService::string2) !== false){
|
|
@@ -135,4 +135,23 @@ class FileUploadService extends Service
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public function createOssUploadBatch($file){
|
|
|
+ if(empty($file['origin']) || empty($file['img_list'])) return;
|
|
|
+ $from = $file['origin'];
|
|
|
+ $filename = str_replace(FileUploadService::string.FileUploadService::string2,'', $from);
|
|
|
+ $timestamp = substr($filename, 0, 8); // 截取前八位数字
|
|
|
+ $date = \DateTime::createFromFormat('Ymd', $timestamp);
|
|
|
+ $date = $date->format('Y-m-d');
|
|
|
+ $dir = FileUploadService::tmp_dir . '/' . $date . '/' . $filename;
|
|
|
+ $realPath = storage_path() . "/app/public/" . $dir;
|
|
|
+
|
|
|
+ foreach ($file['img_list'] as $filename){
|
|
|
+ $filename_tmp = str_replace(FileUploadService::string.FileUploadService::string2,'', $filename);
|
|
|
+ $savePath = self::string3 . $date . '/' . $filename_tmp;
|
|
|
+ list($status,$msg) = (new OssService())->uploadFile($realPath,$savePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ Storage::disk('public')->delete($dir);
|
|
|
+ }
|
|
|
}
|