作者 Karson

优化分片上传配置开关和分片大小

... ... @@ -65,7 +65,7 @@
<!-- 账号信息下拉框 -->
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="{$admin.avatar|cdnurl|htmlentities}" class="user-image" alt="{$admin.nickname|htmlentities}">
<img src="{$admin.avatar|cdnurl|htmlentities}" class="user-image" alt="">
<span class="hidden-xs">{$admin.nickname|htmlentities}</span>
</a>
<ul class="dropdown-menu">
... ... @@ -112,4 +112,4 @@
</ul>
</div>
{/if}
</nav>
\ No newline at end of file
</nav>
... ...
... ... @@ -11,9 +11,6 @@
<label for="c-third" class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="button" id="faupload-third" class="btn btn-danger faupload" data-multiple="true" data-input-id="c-third" ><i class="fa fa-upload"></i> {:__("Upload to third")}</button>
{if config('upload.chunking')}
<button type="button" id="faupload-third-chunk" class="btn btn-danger faupload" data-chunking="true" data-multiple="true" data-input-id="c-third" ><i class="fa fa-upload"></i> {:__("Upload to third by chunk")}</button>
{/if}
</div>
</div>
{/if}
... ... @@ -29,9 +26,6 @@
<label for="c-local" class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="button" id="faupload-local" class="btn btn-primary faupload" data-input-id="c-local" data-url="{:url('ajax/upload')}"><i class="fa fa-upload"></i> {:__("Upload to local")}</button>
{if config('upload.chunking')}
<button type="button" id="faupload-local-chunking" class="btn btn-primary faupload" data-chunking="true" data-input-id="c-local" data-url="{:url('ajax/upload')}"><i class="fa fa-upload"></i> {:__("Upload to local by chunk")}</button>
{/if}
</div>
</div>
... ...
... ... @@ -174,6 +174,14 @@ class Upload
var_dump($array);
}
/**
* 合并分片文件
* @param string $chunkid
* @param int $chunkcount
* @param string $filename
* @return attachment|\think\Model
* @throws UploadException
*/
public function merge($chunkid, $chunkcount, $filename)
{
$filePath = $this->chunkDir . DS . $chunkid;
... ...
... ... @@ -171,6 +171,8 @@ class Config extends Model
'bucket' => 'local',
'maxsize' => $uploadcfg['maxsize'],
'mimetype' => $uploadcfg['mimetype'],
'chunking' => $uploadcfg['chunking'],
'chunksize' => $uploadcfg['chunksize'],
'multipart' => [],
'multiple' => $uploadcfg['multiple'],
];
... ...
... ... @@ -30,4 +30,8 @@ return [
* 是否支持分片上传
*/
'chunking' => false,
/**
* 默认分片大小
*/
'chunksize' => 2097152,
];
... ...
... ... @@ -141,6 +141,9 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
//上传URL
url = url ? url : Config.upload.uploadurl;
url = Fast.api.fixurl(url);
var chunking = Config.upload.chunking || false,
chunkSize = Config.upload.chunksize || 2097152;
//最大可上传文件大小
maxsize = typeof maxsize !== "undefined" ? maxsize : Config.upload.maxsize;
//文件类型
... ... @@ -190,6 +193,8 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
}
return params;
},
chunking: chunking,
chunkSize: chunkSize,
maxFilesize: maxFilesize,
acceptedFiles: mimetype,
maxFiles: (maxcount && parseInt(maxcount) > 1 ? maxcount : (multiple ? null : 1)),
... ...