问题描述:
上传图片成功但是却回显不成功,打开F12显示报: http://localhost:8888/......404
解决方法:
这是因为百度富文本是需要完整链接的需要后端进行配置方可返回完整路径
代码:
$action = $this->request->param('action'); switch($action){ case 'config': $result = file_get_contents(ROOT_PATH.'/public/assets/addons/ueditorbjq/config.json');// json文件的路径 break; case 'uploadimage': $file = $this->request->file('upfile'); if($file){ $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads'); $res = $info->getInfo(); $res['state'] = 'SUCCESS'; $res['url'] = 'http:/xxxxxxxxxxxx/uploads/'.$info->getSaveName(); $result = json_encode($res); } break; case 'uploadvideo': $file = $this->request->file('upfile'); if($file){ $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads'); $res = $info->getInfo(); $res['state'] = 'SUCCESS'; $res['url'] = 'http://xxxxxxxxxxxx/uploads/'.$info->getSaveName(); $result = json_encode($res); } break; case 'uploadfile': $file = $this->request->file('upfile'); if($file){ $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads' . DS . 'file'); $res = $info->getInfo(); $res['state'] = 'SUCCESS'; $res['url'] = 'http://xxxxxxxxxxxx/uploads/file/'.$info->getSaveName(); $result = json_encode($res); } break; default: break; } return $result; }
将xxxxxxxxxxxx换成自己的域名即可