Это редактор в представлении
Код: Выделить всё
ClassicEditor
.create( document.querySelector( '#contenido_en' ), {
simpleUpload: {
// The URL that the images are uploaded to.
uploadUrl: 'admin/pages/upload/',
// Headers sent along with the XMLHttpRequest to the upload server.
headers: {
Authorization: 'Bearer '
}
},
link: {
defaultProtocol: 'https://',
decorators: {
openInNewTab: {
mode: 'manual',
label: 'Abrir en ventana nueva',
attributes: {
target: '_blank',
rel: 'noopener noreferrer'
}
}
}
},
htmlSupport: {
allow: [
{
name: /.*/,
attributes: true,
classes: true,
styles: true
}
]
},
licenseKey: '',
htmlEncodeOutput : true,
mediaEmbed: {
previewsInData: true
},
} )
.then( editor => {
window.editor = editor;
} )
.catch( error => {
console.error( 'Oops, something went wrong!' );
console.error( 'Please, report the following error on https://github.com/ckeditor/ckeditor5/issues with the build id and the error stack trace:' );
console.warn( 'Build id: c6h88q57dj85-kkgxfgc2wty2' );
console.error( error );
} );
Код: Выделить всё
use ResponseTrait;
public function pagesUpload($id = null)
{
helper('form');
$img = $this->request->getFile('upload');
log_message('error',$img ?? 'null');
if ($img->isValid() && ! $img->hasMoved()) {
$newName = $img->getRandomName();
if($id)
{
$img->move(FCPATH . 'public/images/contenido/'.$id.'/', $newName);
$pathimagen = base_url('public/images/contenido/'.$id.'/'.$newName);
}
else{
$img->move(FCPATH . 'public/images/contenido/', $newName);
$pathimagen = base_url('public/images/contenido/'.$newName);
}
$data = ['url' => $pathimagen];
return $this->respond($data);
}
}
$img = $this->request->getFile ('загрузить');
Подробнее здесь: https://stackoverflow.com/questions/781 ... r-ckeditor