更新
This commit is contained in:
parent
b51f7f01df
commit
e0e34aef56
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
|||||||
.env
|
.env
|
||||||
/tests/tmp
|
/tests/tmp
|
||||||
/tests/.phpunit.result.cache
|
/tests/.phpunit.result.cache
|
||||||
|
public
|
@ -44,9 +44,14 @@ class IndexController extends BaseController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function upload(Request $request){
|
public function upload(Request $request){
|
||||||
return json(['code' => 0, 'msg' => 'upload faild']);
|
$file = $request->file('file');
|
||||||
|
if ($file) {
|
||||||
|
$time=time();
|
||||||
|
$file->move(public_path() . DIRECTORY_SEPARATOR . 'uploads/file/'.date('Y-m-d').'/'.$time.'.'.$file->getUploadExtension());
|
||||||
|
return json(['code' => 0, 'msg' => 'upload success','data'=>Env('URL').'/uploads/file/'.date('Y-m-d').'/'.$time.'.'. $file->getUploadExtension()]);
|
||||||
|
}
|
||||||
|
return json(['code' => 1, 'msg' => 'file not found']);
|
||||||
|
|
||||||
$data = $request->post();
|
|
||||||
// 验证数据
|
// 验证数据
|
||||||
$validate = new Validate();
|
$validate = new Validate();
|
||||||
$check = $validate->data($data)->rule([
|
$check = $validate->data($data)->rule([
|
||||||
@ -84,7 +89,8 @@ class IndexController extends BaseController{
|
|||||||
// 合并
|
// 合并
|
||||||
$mergeInfo = $sdk->merge($data['uuid'], $data['chunkLength'], $data['filename']);
|
$mergeInfo = $sdk->merge($data['uuid'], $data['chunkLength'], $data['filename']);
|
||||||
// $mergeInfo = $sdk->merge($data['uuid'], $data['chunkLength'], $data['filename'], 'dirname');
|
// $mergeInfo = $sdk->merge($data['uuid'], $data['chunkLength'], $data['filename'], 'dirname');
|
||||||
// return json(['code' => 1, 'msg' => 'ok', 'data' =>Env('URL'). $mergeInfo]);
|
// return json(['code' => 1, 'msg' => 'ok', 'data' =>$mergeInfo]);
|
||||||
|
return json(['code' => 1, 'msg' => 'ok', 'data' =>Env('URL').'/uploads/'.date('Y-m-d').'/'. $mergeInfo['fileName']]);
|
||||||
} catch (UploadException $e) {
|
} catch (UploadException $e) {
|
||||||
return json(['code' => 0, 'msg' => $e->getMessage()]);
|
return json(['code' => 0, 'msg' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ return [
|
|||||||
// 分片文件大小限制
|
// 分片文件大小限制
|
||||||
'sliceSize' => 0,
|
'sliceSize' => 0,
|
||||||
// 保存根路径
|
// 保存根路径
|
||||||
'rootPath' => public_path() . DIRECTORY_SEPARATOR . 'upload',
|
'rootPath' => public_path() . DIRECTORY_SEPARATOR . 'uploads/file/'.date('Y-m-d'),
|
||||||
// 临时文件存储路径,基于rootPath
|
// 临时文件存储路径,基于rootPath
|
||||||
'tmpPath' => 'tmp'
|
'tmpPath' => 'tmp'
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user