出于安全性考虑,在某些特定情况下,所有的可执行php文件都需要有一定的访问权限。
但是编辑器就不一样了,没有办法设置全选啊。
那么我就抛开自带的上传文件,自己写个方法呗。
在原有的编辑器目录,有upload_json.php这个文件。
果断舍弃。
在页面初始化编辑器配置时,加一行代码。
$(document).ready(function(){var editor;KindEditor.ready(function(K) {editor = K.create('textarea[name="content"]', {allowFileManager : false,height:"350px",uploadJson:"{:url('Admin/Common/edit_uploads')}"//就是这里!});});
})
在公共类库里,创建方法,用的是框架自带的上传方法
public function edit_uploads(){$path='static'.DS.'uploads'.DS.'editor'.DS;$file = request()->file('imgFile');$info = $file->validate(['size' => 8388608, 'ext' => 'jpg,png,gif,jpeg'])->move($path);if($info){$file_path=$info->getSaveName();$file_url=$_SERVER['HTTP_ORIGIN'].DS.$path.$file_path;header('Content-type: text/html; charset=UTF-8');echo json_encode(array('error' => 0, 'url' => $file_url));exit;}else{echo $file->getError();}
}
这样就好了,图片保存的路径都是自定义的,还要怎么样?