我正在使用Angular 4.我已经安装了ng2-ckEditor。现在我想使用ng2-ckEditor从本地系统上传图像。请给我一个建议。
你必须使用PHP上传文件。因为你不能使用ckfinder。因为无论何时运行项目,都不能将node_modules用作外部资源。
你必须简单地创建一个php文件并将代码放入该php文件中
码
// image upload using ckeditor
"uploadUrl": '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json',
"filebrowserImageUploadUrl": 'http://localhost/ckeditor/imageupload.php'
码
<?php
$uploadedFile = $_FILES['upload'];
$path = 'http://localhost/ckeditor/';
move_uploaded_file($uploadedFile['tmp_name'], $path.$uploadedFile)) {
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(1, 'http://localhost/ckeditor/".$uploadedFile['name']."', '');</script>";
}
?>