1、后台编辑器图片上传问题解决

2、文件代码格式化
This commit is contained in:
2016-11-18 16:10:38 +08:00
parent 860da138c9
commit 12709d6cb4
6 changed files with 46 additions and 37 deletions

View File

@@ -61,17 +61,30 @@ class Upload {
}
public function editor() {
$callback = request()->get('callback');
$file = request()->file('upfile');
$info = $file->move(config('editor_upload.rootPath'), true, false);
if ($info) {
$data = $this->parseFile($info);
$data['success'] = true;
$data['file_path'] = $data['url'];
$fileInfo = $this->parseFile($info);
$data = array(
"originalName" => $fileInfo['name'],
"name" => $fileInfo['name'],
"url" => $fileInfo['url'],
"size" => $fileInfo['size'],
"type" => $fileInfo['ext'],
"state" => 'SUCCESS'
);
} else {
$data['success'] = false;
$data['msg'] = "error message";
$data['state'] = $file->getError();
}
/**
* 返回数据
*/
if($callback) {
return '<script>'.$callback.'('.json_encode($data).')</script>';
} else {
return json_encode($data);
}
return $data;
}
public function delete() {