修改文件上传

This commit is contained in:
Anyon 2020-03-28 14:15:27 +08:00
parent 0f13f8145b
commit 8365f130c1
2 changed files with 12 additions and 4 deletions

View File

@ -57,8 +57,8 @@ class Upload extends Controller
*/
public function state()
{
list($this->name, $this->safe) = [input('name', null), intval(input('safe'))];
$data = ['uptype' => $this->getType(), 'xkey' => input('xkey'), 'safe' => $this->safe];
list($this->name, $this->safe) = [input('name', null), $this->getSafe()];
$data = ['uptype' => $this->getType(), 'xkey' => input('xkey'), 'safe' => intval($this->safe)];
if ($info = Storage::instance($data['uptype'])->info($data['xkey'], $this->safe, $this->name)) {
$data['url'] = $info['url'];
$this->success('文件已经上传', $data, 200);
@ -102,7 +102,7 @@ class Upload extends Controller
if (in_array($this->extension, ['php', 'sh'])) {
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 ($this->uptype === 'local') {
$local = LocalStorage::instance();
@ -121,6 +121,15 @@ class Upload extends Controller
}
}
/**
* 获取文件上传类型
* @return boolean
*/
private function getSafe()
{
return boolval(input('safe', '0'));
}
/**
* 获取文件上传方式
* @return string

View File

@ -51,7 +51,6 @@ define(['md5'], function (SparkMD5, allowExtsMimes) {
});
}
}, progress: function (n) {
console.log(arguments)
$('[data-upload-progress]').html(n + '%');
}, done: function (ret, index, file) {
if (++options.count.uploaded >= options.count.total) {