|
|
@@ -13,6 +13,9 @@ use think\Db;
|
|
|
use think\Lang;
|
|
|
use think\Response;
|
|
|
use think\Validate;
|
|
|
+use think\Env;
|
|
|
+use OSS\OssClient;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Ajax异步请求接口
|
|
|
@@ -73,6 +76,9 @@ class Ajax extends Backend
|
|
|
$chunkcount = $this->request->post("chunkcount/d");
|
|
|
$filename = $this->request->post("filename");
|
|
|
$method = $this->request->method(true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if ($action == 'merge') {
|
|
|
$attachment = null;
|
|
|
//合并分片文件
|
|
|
@@ -109,13 +115,22 @@ class Ajax extends Backend
|
|
|
//默认普通上传文件
|
|
|
$file = $this->request->file('file');
|
|
|
try {
|
|
|
- $upload = new Upload($file);
|
|
|
- $attachment = $upload->upload();
|
|
|
+
|
|
|
+ // $upload = new Upload($file);
|
|
|
+ // $attachment = $upload->upload();
|
|
|
+
|
|
|
+ $filename = $file->getInfo();
|
|
|
+ //获取oss实例
|
|
|
+ $ossClient = new OssClient(Env::get('oss.key_id'), Env::get('oss.key_secret'), Env::get('oss.endpoint'));
|
|
|
+ $bucket = Env::get('oss.dbucket');
|
|
|
+ $uploadpath = "tou-biao/" . date("Ymd") . "/" . $filename['name'];
|
|
|
+ $rs = $ossClient->uploadFile($bucket, $uploadpath, $file->getRealPath());
|
|
|
+
|
|
|
} catch (UploadException $e) {
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
|
|
|
- $this->success(__('Uploaded successful'), '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
|
|
|
+ $this->success(__('Uploaded successful'), '', ['url' => $rs['info']['url'], 'fullurl' => $rs['info']['url']]);
|
|
|
}
|
|
|
}
|
|
|
|