mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-26 03:16:36 +08:00
修改文件上传
This commit is contained in:
parent
0f13f8145b
commit
8365f130c1
@ -57,8 +57,8 @@ class Upload extends Controller
|
|||||||
*/
|
*/
|
||||||
public function state()
|
public function state()
|
||||||
{
|
{
|
||||||
list($this->name, $this->safe) = [input('name', null), intval(input('safe'))];
|
list($this->name, $this->safe) = [input('name', null), $this->getSafe()];
|
||||||
$data = ['uptype' => $this->getType(), 'xkey' => input('xkey'), 'safe' => $this->safe];
|
$data = ['uptype' => $this->getType(), 'xkey' => input('xkey'), 'safe' => intval($this->safe)];
|
||||||
if ($info = Storage::instance($data['uptype'])->info($data['xkey'], $this->safe, $this->name)) {
|
if ($info = Storage::instance($data['uptype'])->info($data['xkey'], $this->safe, $this->name)) {
|
||||||
$data['url'] = $info['url'];
|
$data['url'] = $info['url'];
|
||||||
$this->success('文件已经上传', $data, 200);
|
$this->success('文件已经上传', $data, 200);
|
||||||
@ -102,7 +102,7 @@ class Upload extends Controller
|
|||||||
if (in_array($this->extension, ['php', 'sh'])) {
|
if (in_array($this->extension, ['php', 'sh'])) {
|
||||||
return json(['uploaded' => false, 'error' => ['message' => '可执行文件禁止上传到本地服务器']]);
|
return json(['uploaded' => false, 'error' => ['message' => '可执行文件禁止上传到本地服务器']]);
|
||||||
}
|
}
|
||||||
list($this->safe, $this->uptype, $this->name) = [boolval(input('safe')), $this->getType(), input('xkey')];
|
list($this->safe, $this->uptype, $this->name) = [$this->getSafe(), $this->getType(), input('xkey')];
|
||||||
if (empty($this->name)) $this->name = Storage::name($file->getPathname(), $this->extension, '', 'md5_file');
|
if (empty($this->name)) $this->name = Storage::name($file->getPathname(), $this->extension, '', 'md5_file');
|
||||||
if ($this->uptype === 'local') {
|
if ($this->uptype === 'local') {
|
||||||
$local = LocalStorage::instance();
|
$local = LocalStorage::instance();
|
||||||
@ -121,6 +121,15 @@ class Upload extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件上传类型
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private function getSafe()
|
||||||
|
{
|
||||||
|
return boolval(input('safe', '0'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件上传方式
|
* 获取文件上传方式
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -51,7 +51,6 @@ define(['md5'], function (SparkMD5, allowExtsMimes) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, progress: function (n) {
|
}, progress: function (n) {
|
||||||
console.log(arguments)
|
|
||||||
$('[data-upload-progress]').html(n + '%');
|
$('[data-upload-progress]').html(n + '%');
|
||||||
}, done: function (ret, index, file) {
|
}, done: function (ret, index, file) {
|
||||||
if (++options.count.uploaded >= options.count.total) {
|
if (++options.count.uploaded >= options.count.total) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user