edit修改相关内容

This commit is contained in:
admin 2024-01-19 12:00:52 +08:00
parent 1c9ed609f0
commit 4941f0b529
3 changed files with 25 additions and 9 deletions

View File

@ -22,7 +22,7 @@ class Oss
$this->accessKeyId = 'LTAI5tMaDbEbWyQWpwmxp24y';
$this->accessKeySecret = '3bjqbBFC08YIub3c8ry9Elz05UF1J7';
$this->bucket = 'cxgjsz1';
$this->endpoint = 'https://oss-cn-shenzhen.aliyuncs.com';
$this->endpoint = 'http://oss-cn-shenzhen.aliyuncs.com';
try {
if (!isset($this->client)) {

View File

@ -342,7 +342,6 @@ $type = Banner::type();
}
init_page();
});
var ue = UE.getEditor('editor', {
serverUrl: "<?= \Yii::$app->urlManager->createUrl(['file/upload']) ?>",
toolbars: [
@ -398,6 +397,7 @@ $type = Banner::type();
]
]
});
console.log(ue)
<?php $this->endBlock(); ?>
</script>

View File

@ -365,6 +365,7 @@ class UploadController extends \app\controllers\Controller
}
} else {
echo $result;
exit();
}
}
@ -451,7 +452,9 @@ class UploadController extends \app\controllers\Controller
}
$file = md5($_FILES['file']['name']);
// 上传文件的全名
$upload_file = \Yii::$app->basePath . '/web/upload/1/' . $file . '.png';
$explode = explode('.',$_FILES['file']['name']);
$ext = end($explode);
$upload_file = \Yii::$app->basePath . '/web/upload/1/' . $file . '.'.$ext;
// 将上传的文件从临时目录移动到指定目录
if (!move_uploaded_file($_FILES['file']['tmp_name'], $upload_file)) {
$data = [
@ -460,13 +463,13 @@ class UploadController extends \app\controllers\Controller
];
} else {
$oss = new Oss();
$file = '/web/upload/1/' . $file . '.png';
$file_name = '/web/upload/1/' . $file . '.'.$ext;
//上传文件目录
$oss_data = $oss->upload($upload_file, $file);
$oss_data = $oss->upload($upload_file);
if ($oss == false) {
$data = [
'code' => 1,
'msg' => "文件上传失败"
'msg' => "文件上传失败",
];
} else {
$data = [
@ -688,7 +691,6 @@ class UploadController extends \app\controllers\Controller
}
/* 生成上传实例对象并完成上传 */
$up = new Uploader($fieldName, $config, $base64);
/**
* 得到上传文件所对应的各个参数,数组结构
* array(
@ -702,9 +704,23 @@ class UploadController extends \app\controllers\Controller
*/
/* 返回数据 */
/*if($action != 'uploadimage'){
$up = new Uploader($fieldName, $config, $base64);
$fileInfo = $up->getFileInfo();
}else{
}*/
$fileInfo = [];
$re = $this->actionImage();
if(empty($re['code'])){
$fileInfo["url"] = $re['data']['url'];
$fileInfo["type"] = '.png';
$fileInfo["size"] = '0';
$fileInfo["state"] = 'SUCCESS';
}
if ($fileInfo["state"] == "SUCCESS") {
$this->imageCompress($fileInfo);
// $this->imageCompress($fileInfo);
$model = new UploadFile();
$model->user_id = Model::getUserId();
$model->file_url = $fileInfo["url"];