当前位置:首页 » 编程语言 » ckeditorphp

ckeditorphp

发布时间: 2022-04-24 21:28:45

A. ckeditor for php 使用问题。

我用的是Crayon Syntax Highlighter,有一个地方设置是否html转义,

B. ckeditor5上传的图片如何用PHP接收

从图上看应该是传的文件用$_FIELES接收,
如果不行的话试试用file_get_contents('php://input');试试

C. ckeditor+php多图片上传问题。

返回格式因该是:<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction($_GET["CKEditorFuncNum"],路径,'消息')</script>

D. PHP 配置 ckeditor

CKEditor 里面的参数要大写的就得大些,它是会区分大小写的
像BasePath 这些

E. 请问CKEditor 在PHP中如何调用啊

在PHP中调用
<?php
function FCKeditor_IsCompatibleBrowser()
{
if ( isset( $_SERVER ) ) {
$sAgent = $_SERVER['HTTP_USER_AGENT'] ;
}
else {
global $HTTP_SERVER_VARS ;
if ( isset( $HTTP_SERVER_VARS ) ) {
$sAgent = $HTTP_SERVER_VARS['HTTP_USER_AGENT'] ;
}
else {
global $HTTP_USER_AGENT ;
$sAgent = $HTTP_USER_AGENT ;
}
}
if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )
{
$iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;
return ($iVersion >= 5.5) ;
}
else if ( strpos($sAgent, 'Gecko/') !== false )
{
$iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;
return ($iVersion >= 20030210) ;
}
else if ( strpos($sAgent, 'Opera/') !== false )
{
$fVersion = (float)substr($sAgent, strpos($sAgent, 'Opera/') + 6, 4) ;
return ($fVersion >= 9.5) ;
}
else if ( preg_match( "|AppleWebKit/(\d+)|i", $sAgent, $matches ) )
{
$iVersion = $matches[1] ;
return ( $matches[1] >= 522 ) ;
}
else
return false ;
}
class FCKeditor
{
public $InstanceName ;
public $BasePath ;
public $Width ;
public $Height ;
public $ToolbarSet ;
public $Value ;
public $Config ;
public function __construct( $instanceName )
{
$this->InstanceName = $instanceName ;
$this->BasePath = '../common/editor/' ;
$this->Width = '100%' ;
$this->Height = '400' ;
$this->ToolbarSet = 'Default' ;
$this->Value = '' ;
$this->Config = array() ;
}
public function Create()
{
echo $this->CreateHtml() ;
}
public function CreateHtml()
{
$HtmlValue = htmlspecialchars( $this->Value ) ;
$Html = '' ;
if ( $this->IsCompatible() )
{
if ( isset( $_GET['fcksource'] ) && $_GET['fcksource'] == "true" )
$File = 'fckeditor.original.html' ;
else
$File = 'fckeditor.html' ;
$Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}" ;
if ( $this->ToolbarSet != '' )
$Link .= "&Toolbar={$this->ToolbarSet}" ;
$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />" ;
$Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />" ;
$Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>" ;
}
else
{
if ( strpos( $this->Width, '%' ) === false )
$WidthCSS = $this->Width . 'px' ;
else
$WidthCSS = $this->Width ;
if ( strpos( $this->Height, '%' ) === false )
$HeightCSS = $this->Height . 'px' ;
else
$HeightCSS = $this->Height ;
$Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>" ;
}
return $Html ;
}
public function IsCompatible()
{
return FCKeditor_IsCompatibleBrowser() ;
}
public function GetConfigFieldString()
{
$sParams = '' ;
$bFirst = true ;
foreach ( $this->Config as $sKey => $sValue )
{
if ( $bFirst == false )
$sParams .= '&' ;
else
$bFirst = false ;
if ( $sValue === true )
$sParams .= $this->EncodeConfig( $sKey ) . '=true' ;
else if ( $sValue === false )
$sParams .= $this->EncodeConfig( $sKey ) . '=false' ;
else
$sParams .= $this->EncodeConfig( $sKey ) . '=' . $this->EncodeConfig( $sValue ) ;
}
return $sParams ;
}
public function EncodeConfig( $valueToEncode )
{
$chars = array(
'&' => '%26',
'=' => '%3D',
'"' => '%22' ) ;
return strtr( $valueToEncode, $chars ) ;
}
}
$editor = new FCKeditor('editor') ;//接收时$_POST['........']中的内容
$editor->BasePath = "../common/editor/";//FCKEDITOR的路径
?>
在需要调用的地方<?php $editor->Create();?>
接受的文件用$_POST['editor']调用(editor)可在$editor = new FCKeditor('editor')设置

F. php怎么调用ckeditor

将FCKeditor放在网站根目录
在PHP文件里面,包含/FCKeditor/ckeditor/" target="_blank">fckeditor.php文件
在网页中需要放置该编辑器的地方插入下面代码即可调用:
代码如下 复制代码
1 <?php

//包含fckeditor类

include("fckeditor/fckeditor.php") ;

//创建一个FCKeditor,表单名称为 jzleditor

$oFCKeditor = new FCKeditor("jzleditor");

//设置编辑器路径

$oFCKeditor->BasePath = "fckeditor/";

$oFCKeditor->ToolbarSet = "Default";//工具按钮

$oFCKeditor->Value =$cont; //;设置初始内容

$oFCKeditor->Width="100%"; //设置它的宽度

$oFCKeditor->Height="550px"; //设置它的高度

$oFCKeditor->Create();

我还有在后盾网学习呢,加油(ง •̀_•́)งฅ ̳͒•ˑ̫• ̳͒ฅ♡

G. PHP中CKEditor的使用

<input name="subject" type="text" >

<?php
include './ckeditor/ckeditor.php'; //include ckeditor.php
$ckeditor = new CKEditor;
//include './ckfinder/ckfinder.php';
$ckeditor->editor('content');
//CKFinder::SetupCKEditor($ckeditor, true, true);

?>
<input name="submit" type="submit" value="提交" />

H. php下怎么使用多个ckeditor 在线编辑器

CKeditor是一款在线编辑器,可用于博客、新闻发布等的文本编辑框,利用它可以很方便地实现对文章的排版。它是一款开源工具,可以在我们的网站中使用它增强编辑功能,显得专业和装B。原来它叫FCKeditor,后来改名叫CKeiditor,感谢开源软件的开发者,他们是最帅的!

一、下载

官网下载:http://ckeditor.com/download/

解压之后直接放在网站根目录里就可以使用了。

在_samples目录下,可以找到很多做好的样例,这些可以用来学习编辑器的用法。

二、用js的方式调用

官方演示样例:

复制代码
<html>
<head>
<title>Sample CKEditor Site</title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
<form method="post">
<p>
My Editor:<br />
<textarea id="editor1" name="editor1"><p>Initial value.</p></textarea>
<script type="text/javascript">
CKEDITOR.replace( 'editor1' );
</script>
</p>
<p>
<input type="submit" />
</p>
</form>
</body>
</html>
复制代码
我是把ckeditor目录和test.html放在同个目录下,注意第四行原来是src="/ckeditor/ckeditor.js",要把前面的斜杠去掉,改为src="ckeditor/ckeditor.js"才能正确指向文件ckeditor.js。这时候不启用wamp服务器也能正确显示ckeditor。

三、用PHP的方法引入

复制代码
<p>Title:</p><input name="subject" type="text" >

<?php
include 'ckeditor/ckeditor.php'; //include ckeditor.php
$ckeditor = new CKEditor;
$ckeditor->editor('content');

?>

<input name="submit" type="submit" value="提交" />
复制代码
这样也能引入ckeditor,这时候editor的位置就在中间那段php代码的地方,两种方法都可以,不过我还不明白两种方法有什么区别。

还可以在textarea标签中嵌入ckeditor:

复制代码
<?php

if(!empty($_POST["sub"]))
{
echo $_POST["title"];
echo "<br>";
echo $_POST["content"];
}

?>
<html>
<head>
<title>Sample CKEditor Site</title>
</head>
<body>
<form method="post">
<p>
My Editor:<br />
<input type="text" name="title">
<textarea name="content">
<?php
include 'ckeditor/ckeditor.php'; //include ckeditor.php
$ckeditor = new CKEditor;
$ckeditor->editor('content');
?>
</textarea>
</p>
<p>
<input type="submit" name="sub"/>
</p>
</form>
</body>
</html>

I. php 引用ckeditor出现的问题!!

可能是数据表字段长度不够,所以超出部分没有存进去,把数据表字段修改的长一点。

J. 如何将CKeditor编辑器的上传和thinkphp结合

当我们在模板中,将ckeditor配置好后,需要在JS代码中进行一些调整或修改,如下:
CKEDITOR.replace( 'v_content', {
filebrowserImageUploadUrl : '/Files/ck_upload.shtml'
});
复制代码
这里是在JS部分进行了修改,指定了当使用编辑器的图片功能时,上传的请求地址在那里。一般来说ckeditor是不带上传的,你把上面的配置调整好后,点击图片,就会出现上传功能,但是只是个架子,没有实际效果。具体的处理请看下面:
function ck_upload($ftype = 'image')
{
if($ftype == 'image'){
$ftype = array('jpg', 'gif', 'png', 'jpeg', 'bmp');
}

header("Content-type:text/html");
import('ORG.Net.UploadFile');
$upload = new UploadFile(); // 实例化上传类
$upload->maxSize = -1; // 设置附件上传大小
$upload->allowExts = $ftype; // 设置附件上传类型
$upload->savePath = './Public/Uploads/'; // 设置附件上传目录
$upload->autoSub = true;
$upload->subType = 'date';
if (!$upload->upload()) {// 上传错误提示错误信息
echo "<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction(".$this->_get('CKEditorFuncNum').", '/', '上传失败," . $upload->getErrorMsg() . "!');</script>";
} else {
//// 上传成功 获取上传文件信息并存入数据库
$info = $upload->getUploadFileInfo();
//获取具体的路径,用于返回给编辑器
$savepath = $info[0]['savepath'].$info[0]['savename'];
//下面的输出,会自动的将上传成功的文件路径,返回给编辑器。
echo "<script type=\"text/javascript\">window.parent.CKEDITOR.tools.callFunction(".$this->_get('CKEditorFuncNum').",'$savepath','');</script>";
}
}
复制代码
会发现TP的代码里,有两端是输出JS的,一个是报错,一个是返回图片,这个自己看一下,就能懂的。很简单的。

上传完成后,如下图,我使用的是防盗链模式,所以图片路径是.shtml,如果你按照上面的方式,那么你的返回路径可能是upload/img/abc.jpg之类的。

代码肯定没问题的,我N个项目里在用,这样做的目的是,我能控制文件了,能控制它的上传时间,对文件进行权限管理等等,这些都是很方便的。另外,在附送一个防盗链的方法,前提是,将图片路径存在数据库里。

我这里,文件的表示使用的是id标示:
function getfile($id) {
$res = M('files')->find($id);
$file = $res['savepath'];
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($file));
header('Content-Transfer-Encoding: binary');
header('Pragma: public');
$sTmpVar = fread(fopen($file, 'r'), filesize($file));
echo $sTmpVar;
}
}
复制代码
将就看下把,$res['savepath']就是数据库里的文件路径,这个方法照抄就行了。这样你就能把upload/img/xxx.jpg转化成诸如file/1022.shtml之类的URL了

热点内容
小飞机android 发布:2025-07-16 16:51:00 浏览:235
python获取api 发布:2025-07-16 16:35:28 浏览:739
安卓应用耗电优化是什么 发布:2025-07-16 16:29:39 浏览:501
惠普电脑都有什么配置的 发布:2025-07-16 15:51:49 浏览:520
hadoop编译native 发布:2025-07-16 15:48:57 浏览:256
checksum的算法 发布:2025-07-16 15:48:50 浏览:846
jqueryeasyui上传 发布:2025-07-16 15:40:06 浏览:470
linux程序设计第4版pdf 发布:2025-07-16 14:52:14 浏览:515
底层架算法 发布:2025-07-16 14:52:07 浏览:66
摄影存储卡哪种好 发布:2025-07-16 14:41:51 浏览:626