|
@@ -58,7 +58,7 @@ class Save
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- public function act($id, $source, $default_ext = '', $uid = false)
|
|
|
+ public function act($id, $source, $default_ext = '', $uid = false, $dest_name = '', $cate = 1)
|
|
|
{
|
|
|
$this->init($id);
|
|
|
$name = '';
|
|
@@ -150,10 +150,13 @@ class Save
|
|
|
}
|
|
|
Dever::error($state);
|
|
|
}
|
|
|
+ if ($dest_name) {
|
|
|
+ $name = $dest_name;
|
|
|
+ }
|
|
|
$dest = $this->config['id'] . '/' . $this->getDest($name, $ext, $uid);
|
|
|
# type 1是文件复制 2是base64 3是远程文件复制
|
|
|
$url = Dever::load('tool', 'upload')->get($this->config['save'])->upload($type, $source, $dest, $chunk, $this);
|
|
|
- $data = $this->up($source_name, $name, $dest, $this->config['size'], $this->config['width'] ?? 0, $this->config['height'] ?? 0);
|
|
|
+ $data = $this->up($source_name, $name, $dest, $this->config['size'], $this->config['width'] ?? 0, $this->config['height'] ?? 0, $cate);
|
|
|
$data['url'] = $url;
|
|
|
$data['type'] = $this->type;
|
|
|
if (isset($content)) {
|
|
@@ -176,7 +179,7 @@ class Save
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
- private function up($source_name, $name, $dest, $size, $width = 0, $height = 0)
|
|
|
+ private function up($source_name, $name, $dest, $size, $width = 0, $height = 0, $cate = 1)
|
|
|
{
|
|
|
$file['rule_id'] = $this->config['id'];
|
|
|
$file['name'] = $name;
|
|
@@ -191,6 +194,7 @@ class Save
|
|
|
if ($height) {
|
|
|
$data['height'] = $height;
|
|
|
}
|
|
|
+ $data['cate_id'] = $cate;
|
|
|
$data['id'] = Dever::db('file', 'upload')->up($file, $data);
|
|
|
return $data;
|
|
|
}
|
|
@@ -303,7 +307,9 @@ class Save
|
|
|
$dest = DIRECTORY_SEPARATOR . substr($id, 0, 3) . DIRECTORY_SEPARATOR . substr($id, 3, 2) . DIRECTORY_SEPARATOR . substr($id, 5, 2) . DIRECTORY_SEPARATOR . $uid . '.' . $ext;
|
|
|
$name = $uid;
|
|
|
} else {
|
|
|
- $name = md5($name);
|
|
|
+ if (!strpos($name, '_')) {
|
|
|
+ $name = md5($name);
|
|
|
+ }
|
|
|
$path = array_slice(str_split($name, 2), 0, 3);
|
|
|
$dest = implode(DIRECTORY_SEPARATOR, $path) . DIRECTORY_SEPARATOR . $name . '.' . $ext;
|
|
|
}
|