添加上传到相册功能
This commit is contained in:
Regular → Executable
+11
-5
@@ -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;
|
||||
|
||||
Regular → Executable
+8
@@ -24,6 +24,8 @@
|
||||
</div>
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<input id="image" style="display: none;" type="file" multiple name="image" accept="image/*">
|
||||
<br>
|
||||
<input id="album" class="input-group form-control" type="text" name="album" placeholder="上传到相册" tabindex="500">
|
||||
</form>
|
||||
<div class="success-info">
|
||||
<div class="mdui-tab mdui-tab-scrollable" mdui-tab>
|
||||
@@ -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: "<i class=\"glyphicon glyphicon-picture\"></i> ",
|
||||
|
||||
Regular → Executable
+12
@@ -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' => [
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user