From dce1376b70ec6bdc71a166986b00f05d818a9993 Mon Sep 17 00:00:00 2001 From: ctaoist Date: Wed, 20 Nov 2019 15:07:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8A=E4=BC=A0=E5=88=B0?= =?UTF-8?q?=E7=9B=B8=E5=86=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/index/controller/Upload.php | 16 +++++++++++----- application/index/view/index/index.html | 8 ++++++++ config/naming.php | 12 ++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) mode change 100644 => 100755 application/index/controller/Upload.php mode change 100644 => 100755 application/index/view/index/index.html mode change 100644 => 100755 config/naming.php diff --git a/application/index/controller/Upload.php b/application/index/controller/Upload.php old mode 100644 new mode 100755 index 33ba833d..3a5aa60f --- a/application/index/controller/Upload.php +++ b/application/index/controller/Upload.php @@ -210,11 +210,17 @@ class Upload extends Base $pathRule = $this->config['path_naming_rule']; $fileRule = $this->config['file_naming_rule']; - $path = trim(str_replace( - array_column($naming['path'], 'name'), - array_column($naming['path'], 'value'), - $pathRule - ), '/'); + if ($pathRule === '{input}') { + $path = trim($_POST['album'], '/'); + } elseif ($pathRule === '{input_with_user}') { + $path = trim($this->user->username . '/' . $_POST['album'], '/'); + } else { + $path = trim(str_replace( + array_column($naming['path'], 'name'), + array_column($naming['path'], 'value'), + $pathRule + ), '/'); + } if ($fileRule === '{original}') { $file = $name; diff --git a/application/index/view/index/index.html b/application/index/view/index/index.html old mode 100644 new mode 100755 index 1209cc3f..4b80e18e --- a/application/index/view/index/index.html +++ b/application/index/view/index/index.html @@ -24,6 +24,8 @@
+
+
@@ -100,6 +102,12 @@ //browseClass: "btn btn-file", maxFileSize: "{$config.upload_max_size / 1024}",// kb maxFileCount: "{$config.upload_single_num}", + uploadExtraData: function(previewId, index) { + var data = { + album : $('#album').val(), + }; + return data; + }, showCaption: true, dropZoneEnabled: true, browseIcon: " ", diff --git a/config/naming.php b/config/naming.php old mode 100644 new mode 100755 index 366339a9..3fe11ad9 --- a/config/naming.php +++ b/config/naming.php @@ -87,6 +87,18 @@ return [ 'explain' => '16位随机字符串', 'value' => str_rand(), ], + [ + 'name' => '{input}', + 'example' => 'life、宠物', + 'explain' => '上传到相册名字,上传时由用户输入指定,比如上传时输入 life,则会上传到 path-store/life/文件夹下', + 'value' => $md5, + ], + [ + 'name' => '{input_with_user}', + 'example' => 'life、宠物', + 'explain' => '上传到相册名字,上传时由用户输入指定,路径带有当前用户名前缀,比如上传时输入 life,则会上传到: path-store/username/life/文件夹下', + 'value' => $md5, + ], ], 'file' => [ [