java 如何利用ckeditor实现文件(html格式或者word格式)上传并把文件中内容保存到数据库中?

java 如何利用ckeditor实现文件(html格式或者word格式)上传并把文件中内容保存到数据库中?,第1张

打开:

将word在后台转换为htm,将htm内容传到前台,在editor内面通过html方式加载该内容。。。

保存:

将editor内容保存为htm文件,将htm文件转化为doc。。。

给你借鉴一下,新闻发布:

News_add.asp页面代码

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td align="center" valign="top">

<table width="95%" border="0" cellpadding="2" cellspacing="1" class="table_southidc">

<form method="POST" name="myform" onSubmit="return CheckForm()" action="News_save.asp?action=Add" target="_self">

<tr align="center">

<td class="back_southidc" height="30" colspan="2"><font color="#0000FF"><strong>新增新闻</strong></font></td>

</tr>

<tr bgcolor="#ECF5FF">

<td width="20%" height="24" align="right"><div align="left"><font color="#FF0000">*</font>新

闻标题:</div></td>

<td width="80%" valign="top">

<div align="left">

<input name="title" type="text" class="input" value="" size="50" maxlength="200">

</div></td>

</tr>

<tr bgcolor="#ECF5FF">

<td height="24" align="right"><div align="left"><font color="#FF0000">*</font>新闻类别:</div></td>

<td valign="top">

新闻大类:

<%

set rs= Server.CreateObject("ADODB.Recordset")

sql = "select * from BigClass_New"

rs.open sql,conn,1,1

if rs.eof and rs.bof then

response.write "请先添加栏目。"

else

%>

<select name="BigClassName" onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)" size="1">

<option selected value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>

<%

dim selclass

selclass=rs("BigClassName")

rs.movenext

do while not rs.eof

%>

<option value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>

<%

rs.movenext

loop

end if

rs.close

%>

</select>

<select name="SmallClassName">

<option value="" selected>不指定小类</option>

<%

set rs= Server.CreateObject("ADODB.Recordset")

sql="select * from SmallClass_New where BigClassName='" &selclass &"'"

rs.open sql,conn,1,1

if not(rs.eof and rs.bof) then

%>

<option value="<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option>

<% rs.movenext

do while not rs.eof%>

<option value="<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option>

<%

rs.movenext

loop

end if

rs.close

%>

</select>

</td>

</tr>

<tr bgcolor="#ECF5FF">

<td align="right" valign="top"><div align="left"><font color="#FF0000">*</font>新闻内容:</div></td>

<td valign="top">

<input type="hidden" name="content" value="">

<iframe ID="eWebEditor1" src="Southidceditor/ewebeditor.asp?id=content&style=southidc" frameborder="0" scrolling="no" width="620" HEIGHT="405"></iframe>

</td>

</tr>

<tr bgcolor="#ECF5FF">

<td height="24" align="right"><div align="left">首页图片:

<input name="IncludePic" type="hidden" id="IncludePic" value="yes">

</div></td>

<td valign="top"><input name="DefaultPicUrl" type="text" id="DefaultPicUrl" value="" size="50" maxlength="200">

</td>

</tr>

<tr bgcolor="#ECF5FF">

<td height="24" align="right"><div align="left"><font color="#FF0000">*</font>发布人:</div></td>

<td valign="top">

<div align="left">

<input name="user" type="text" class="input" size="30" value="admin">

</div></td>

</tr>

<tr bgcolor="#ECF5FF">

<td height="24" align="right"><div align="left">首页图片新闻:</div></td>

<td>

<div align="left">

<input type="radio" value="true" name="OK">

<input type="radio" value="false" checked name="Ok">

否 <font color="#FF0000">(设为首页图片新闻,选择此项时请注意文章中是否添加有图片!)</font></div></td>

</tr>

<tr align="center" bgcolor="#ECF5FF">

<td height="35"><div align="left">录入时间:</div></td>

<td height="35"><div align="left">

<input name="AddDate" type="text" id="AddDate" value="<%=date()%>" maxlength="50">

</div></td>

</tr>

<tr align="center" bgcolor="#ECF5FF">

<input type="hidden" name="Id" value="108">

<td height="35" colspan="2"><input type="submit" name="Submit" value="提交" class="input">

<input type="reset" name="Submit" value="重置" class="input"></td>

</tr>

</form>

</table>

</tr>

</table>

<table width="100%" height="28" border="0" cellpadding="0" cellspacing="0" class="HeaderTdStyle">

<tr>

<td>

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="2">

<tr>

<td align="right">Design By <a href="mailto:sales@zhongxinkeji.com">ZXKJ</a></td>

</tr>

</table></td>

</tr>

</table>

处理页面News_save.asp代码:

<!--#include file="conn.asp"-->

<%

if Request.QueryString("action")="Add" then

set rs= Server.CreateObject("ADODB.Recordset")

sql="select * from News"

rs.open sql,conn,1,3

If request.form("Title")="" Then

Response.Write("<script language=""JavaScript"">alert(""错误:您没输入标题,请返回检查!!"")history.go(-1)</script>")

response.end

end if

If request.form("content")="" Then

Response.Write("<script language=""JavaScript"">alert(""错误:您没输入新闻内容,请返回检查!!"")history.go(-1)</script>")

response.end

end if

If request.form("user")="" Then

Response.Write("<script language=""JavaScript"">alert(""错误:您没输入发布人,请返回检查!!"")history.go(-1)</script>")

response.end

end if

rs.addnew

rs("Title")=request.form("Title")

rs("Content")=request.form("content")

rs("BigClassName")=request.form("BigClassName")

rs("SmallClassName")=request.form("SmallClassName")

rs("FirstImageName")=request.form("DefaultPicUrl")

rs("User")=request.form("user")

rs("AddDate")=request.form("AddDate")

rs("Ok")=request.form("Ok")

rs.update

rs.close

set rs=nothing

response.Redirect "News_Manage.asp"

end if

%>

<td><textarea rows="20" cols="120" name="content"></textarea></td>

<script type="text/javascript" src="../fckeditor/ckeditor.js"></script>

<script type="text/javascript">

<!--

FCKEDITOR.replace("content")

function ccc(){

return CKEDITOR.instances.content.getData()

}

//-->

</script>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9821748.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-02
下一篇 2023-05-02

发表评论

登录后才能评论

评论列表(0条)

保存