使用ng2-ckeditor从本地系统上传图像

问题描述 投票:0回答:1

我正在使用Angular 4.我已经安装了ng2-ckEditor。现在我想使用ng2-ckEditor从本地系统上传图像。请给我一个建议。

angular ckeditor image-uploading
1个回答
0
投票

你必须使用PHP上传文件。因为你不能使用ckfinder。因为无论何时运行项目,都不能将node_modules用作外部资源。

你必须简单地创建一个php文件并将代码放入该php文件中

  1. 将此代码放在.ts文件中

// image upload using ckeditor
"uploadUrl": '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json',
"filebrowserImageUploadUrl": 'http://localhost/ckeditor/imageupload.php'
  1. 在root上创建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>";
}

?>
© www.soinside.com 2019 - 2024. All rights reserved.