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->accessKeyId = 'LTAI5tMaDbEbWyQWpwmxp24y';
$this->accessKeySecret = '3bjqbBFC08YIub3c8ry9Elz05UF1J7'; $this->accessKeySecret = '3bjqbBFC08YIub3c8ry9Elz05UF1J7';
$this->bucket = 'cxgjsz1'; $this->bucket = 'cxgjsz1';
$this->endpoint = 'https://oss-cn-shenzhen.aliyuncs.com'; $this->endpoint = 'http://oss-cn-shenzhen.aliyuncs.com';
try { try {
if (!isset($this->client)) { if (!isset($this->client)) {

View File

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

View File

@ -365,6 +365,7 @@ class UploadController extends \app\controllers\Controller
} }
} else { } else {
echo $result; echo $result;
exit();
} }
} }
@ -451,7 +452,9 @@ class UploadController extends \app\controllers\Controller
} }
$file = md5($_FILES['file']['name']); $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)) { if (!move_uploaded_file($_FILES['file']['tmp_name'], $upload_file)) {
$data = [ $data = [
@ -460,13 +463,13 @@ class UploadController extends \app\controllers\Controller
]; ];
} else { } else {
$oss = new Oss(); $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) { if ($oss == false) {
$data = [ $data = [
'code' => 1, 'code' => 1,
'msg' => "文件上传失败" 'msg' => "文件上传失败",
]; ];
} else { } else {
$data = [ $data = [
@ -688,7 +691,6 @@ class UploadController extends \app\controllers\Controller
} }
/* 生成上传实例对象并完成上传 */ /* 生成上传实例对象并完成上传 */
$up = new Uploader($fieldName, $config, $base64);
/** /**
* 得到上传文件所对应的各个参数,数组结构 * 得到上传文件所对应的各个参数,数组结构
* array( * array(
@ -702,9 +704,23 @@ class UploadController extends \app\controllers\Controller
*/ */
/* 返回数据 */ /* 返回数据 */
$fileInfo = $up->getFileInfo(); /*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") { if ($fileInfo["state"] == "SUCCESS") {
$this->imageCompress($fileInfo); // $this->imageCompress($fileInfo);
$model = new UploadFile(); $model = new UploadFile();
$model->user_id = Model::getUserId(); $model->user_id = Model::getUserId();
$model->file_url = $fileInfo["url"]; $model->file_url = $fileInfo["url"];