|
@@ -163,4 +163,40 @@ if (!function_exists('randomkeys')) {
|
|
|
}
|
|
|
return $returnStr;
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//上传图片
|
|
|
+/**
|
|
|
+ * @param $files
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+if (!function_exists('UploadImg')) {
|
|
|
+
|
|
|
+ function UploadImg($files): array
|
|
|
+ {
|
|
|
+ $savename = [];
|
|
|
+ $files = !is_array($files) ? [$files] : $files;
|
|
|
+ //验证
|
|
|
+ validate([
|
|
|
+ 'imgFile' => [
|
|
|
+ 'fileSize' => 10240000,
|
|
|
+ 'fileExt' => 'jpg,jpeg,png,bmp,gif',
|
|
|
+ 'fileMime' => 'image/jpeg,image/png,image/gif'
|
|
|
+ ]
|
|
|
+ ])->check(['imgFile' => $files]);
|
|
|
+
|
|
|
+ foreach ($files as $file) {
|
|
|
+ $url = Filesystem::disk('public')
|
|
|
+ ->putFile('topic/' . date("Ymd"), $file, function () use ($file) {
|
|
|
+ return str_replace('.' . $file->getOriginalExtension(), '', $file->getOriginalName() . "_" . date('YmdHis'));
|
|
|
+ });
|
|
|
+ $name = str_replace('.' . $file->getOriginalExtension(), '', $file->getOriginalName());
|
|
|
+ $temp = ["url" => $url, "name" => $name];
|
|
|
+ $savename[] = $temp;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $savename;
|
|
|
+
|
|
|
+ }
|
|
|
+}
|