當前位置:首頁 » 文件管理 » fckeditor圖片上傳java

fckeditor圖片上傳java

發布時間: 2022-07-28 08:43:47

㈠ Fckeditor java 上傳圖片後並且獲取他的全部路徑

沒聽過 Fckeditor 得到物理路徑是 GetRealPath(String) 裡面可以傳個session里的變數給它 ,拿到後處理一下就是工程目錄了, 建議資料庫存放
相對路徑。

㈡ java下FCKeditor上傳圖片問題

先到tomcat->webapps里建立一個文件夾叫mysite。把FCKeditor里的/editor和fckconfig.js, fckeditor.js, fckstyles.xml, fcktemplates.xml四個文件到mysite文件夾里,因為別的文件對我們來說沒有什麼意義。再把FCKeditor.java 2.3中的web目錄下的WEB-INF目錄到mysite下(裡面有commons-fileupload.jar, FCKeditor-2.3.jar,web.xml等幾個文件), 把其中的src目錄下的FCKeditor.tld文件到mysite/WEB-INF/下.這樣它才支持JSP。

下面我們要對其中的一些文件進行修改:
打開fckconfig.js 文件,修改 FCKConfig.DefaultLanguage = ''zh-cn'' ;
把FCKConfig.LinkBrowserURL等的值替換成以下內容:
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" ;

FCKConfig.ImageBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" ;

FCKConfig.FlashBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" ;

FCKConfig.LinkUploadURL = FCKConfig.BasePath + ''filemanager/upload/simpleuploader?Type=File'' ;

FCKConfig.FlashUploadURL = FCKConfig.BasePath + ''filemanager/upload/simpleuploader?Type=Flash'' ;

FCKConfig.ImageUploadURL = FCKConfig.BasePath + ''filemanager/upload/simpleuploader?Type=Image'' ;

打開WEB-INF下面的web.xml文件:
把SimpleUploader中的配置屬性enabled定義為true(開啟文件上傳功能)
添加標簽定義:
<taglib>
<taglib-uri>/mysite</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location>
</taglib>

這樣文件就設置完了,這時建立一個jsp文件試試:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="java.util.*" import="java.text.*" errorPage="" %>
<%@ page language="java" import="com.fredck.FCKeditor.*" %>
<%@ taglib uri="/mysite" prefix="FCK" %>
<script type="text/javascript" src="/mysite/fckeditor.js"></script>
<form method="POST" action="Bs_Bulletin_save.jsp">
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="19%" bgcolor="#F0F0F0" height="25" align="right">標題:</td>
<td width="81%" bgcolor="#F0F0F0"><INPUT TYPE="text" NAME="title" size="58"></td>
</tr>
<tr>
<td width="19%" height="300" bgcolor="#F0F0F0">
<div align="center">中文信息設置<BR><BR>
<span style="color: #FF0000">支持html(圖片大小寬度不要超過170個象素)</span></div>
</td>
<td width="81%" bgcolor="#F0F0F0">
<textarea name="content" cols="58" rows="15"></textarea>
<script type="text/javascript">
var oFCKeditor = new FCKeditor(''content'') ;
oFCKeditor.BasePath = "/mysite/" ;
oFCKeditor.Height = 400;
oFCKeditor.ToolbarSet = "Default" ;
oFCKeditor.ReplaceTextarea();
</script>
</td>
</tr>
<tr>
<td width="19%" height="25" bgcolor="#F0F0F0">發布時間:</td>
<td width="81%" bgcolor="#F0F0F0"><INPUT TYPE="text" NAME="datatimes" value="<%=time%>" size="58"></td>
</tr>

<tr>
<td colspan="2" bgcolor="#F0F0F0">
<div align="center"><input type="submit" value=" 添 加 " name="cmdok"><input type="reset" value=" 重 寫 " name="cmdcancel"></div></td>
</tr>
</table>
</form>

加紅字的部分,就是調用這個在線編輯器了。現在上傳的圖看一下,提示internal server error 500,還記得一開始時,我們提到的xalan.jar嗎,現在把xalan.jar放到lib文件夾里,關掉tomcat再重起一下,應該好用了……

注意,如果想把這個控制項融入你現有的web應用系統中,就不需要新建mysite了,你可以這樣做:

1、把FCKeditor里的/editor和fckconfig.js, fckeditor.js, fckstyles.xml, fcktemplates.xml四個文件直接到現有web應用的某個目錄下。

2、把FCKeditor.java 2.3中WEB-INF目錄里的commons-fileupload.jar, FCKeditor-2.3.jar放在現有系統的lib目錄下。

3、在現有系統的web.xml中加入FCKeditor.java 2.3中web.xml的配置信息,並添加標簽定義:
<taglib>
<taglib-uri>/mysite</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location>
</taglib>
這里別忘了把SimpleUploader中的配置屬性enabled定義為true以開啟文件上傳功能!

4、然後把FCKeditor.tld文件到現有系統的WEB-INF/下,這樣就可以了。當然,FCKeditor.tld的位置不是絕對的,你可以放在其它地方,只要在前面的標簽定義中指定相應的位置就行了。

附:FCKeditor.java中web.xml配置信息
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<param-value>/UserFiles/</param-value><!--上傳附件所在根路徑 -->
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value><!--啟動服務時是否顯示調試信息 -->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SimpleUploader</servlet-name>
<servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
<init-param>
<param-name>baseDir</param-name>
<param-value>/UserFiles/</param-value><!--上傳附件所在根路徑 -->
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>false</param-value><!--啟動服務時是否顯示調試信息 -->
</init-param>
<init-param>
<param-name>enabled</param-name>
<param-value>true</param-value><!--是否開啟上傳文件功能 -->
</init-param>
<init-param>
<param-name>AllowedExtensionsFile</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFile</param-name>
<param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsImage</param-name>
<param-value>jpg|gif|jpeg|png|bmp</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsImage</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>AllowedExtensionsFlash</param-name>
<param-value>swf|fla</param-value>
</init-param>
<init-param>
<param-name>DeniedExtensionsFlash</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>/webapp/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern><!--FCKeditor所在目錄,即/editor和fckconfig.js, fckeditor.js, fckstyles.xml, fcktemplates.xml四個文件所在目錄 -->
</servlet-mapping>

<servlet-mapping>
<servlet-name>SimpleUploader</servlet-name>
<url-pattern>/webapp/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern><!--FCKeditor所在目錄 -->
</servlet-mapping>

<taglib>
<taglib-uri>/home/project/law/FCKeditor</taglib-uri>
<taglib-location>/WEB-INF/FCKeditor.tld</taglib-location><!--FCKeditor.tld路徑 -->
</taglib>

㈢ fckeditor圖片上傳路徑設置(jsp)

你好,這個問題你是問對人了。java版本的fckeditor我有研究,曾經低版本的fckeditor是可以放到其他非應用目錄下的,高版本的fckeditor考慮到安全性只能放到應用目錄下了。具體的你可以通過看fckeditor.jar中class寫法,是固定死的。
當然可以通過反編譯fckeditor.jar中的class,來達到修改到非應用目錄下。這個我干過!

㈣ FCKeditor 上傳文件大小如何限制

方法如下:
/// 獲取允許上傳的類型
/// </summary>
protected string UserUploadType
...{
get
...{
if (sUserUploadType == null)
...{
// Try to get from the "Application".
sUserUploadType = (string)Application["FCKeditor:UserUploadType"];
// Try to get from the "Session".
if (sUserUploadType == null || sUserUploadType.Length == 0)
...{
sUserUploadType = (string)Session["FCKeditor:UserUploadType"];
// Try to get from the Web.config file.
if (sUserUploadType == null || sUserUploadType.Length == 0)
...{
sUserUploadType = System.Web.Configuration.WebConfigurationManager.AppSettings["FCKeditor:UserUploadType"];
// Otherwise use the default value.
if (sUserUploadType == null || sUserUploadType.Length == 0)
sUserUploadType = DEFAULT_USER_FILES_UPLOADTYPE;
}
}
// Check that the user path starts and ends with slash (".")
if (!sUserUploadType.StartsWith("."))
sUserUploadType = "." + sUserUploadType;
if (!sUserUploadType.EndsWith("."))
sUserUploadType += ".";
}
return sUserUploadType;
}
}
/**//// <summary>
/// 獲取允許上傳的文件最大限制
/// </summary>
protected int UserUploadSize
...{
get
...{
if (iUserUploadSize < 1)
...{
iUserUploadSize = Convert.ToInt32(Application["FCKeditor:UserUploadSize"]);
if (iUserUploadSize < 1)
...{
iUserUploadSize = Convert.ToInt32(Session["FCKeditor:UserUploadSize"]);
if (iUserUploadSize < 1)
...{
iUserUploadSize = Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["FCKeditor:UserUploadSize"]);
if (iUserUploadSize < 1)
...{
iUserUploadSize = DEFAULT_USER_FILES_UPLOADSIZE;
}
}
}
}
return iUserUploadSize;
}
}
}
}
接著就是對點擊"瀏覽伺服器"頁面的上傳部分的修改
以下是對FileBrowserConnector.cs中的FileUpload()函數的修改
private void FileUpload(string resourceType, string currentFolder)
...{
HttpPostedFile oFile = Request.Files["NewFile"];
string sErrorNumber = "0";
string sFileName = "";
if (oFile != null && oFile.ContentLength > 0)
...{
// Map the virtual path to the local server path.
string sServerDir = this.ServerMapFolder(resourceType, currentFolder);
/**//*
// Get the uploaded file name.
sFileName = System.IO.Path.GetFileName( oFile.FileName ) ;
int iCounter = 0 ;
while ( true )
{
string sFilePath = System.IO.Path.Combine( sServerDir, sFileName ) ;
if ( System.IO.File.Exists( sFilePath ) )
{
iCounter++ ;
sFileName =
System.IO.Path.GetFileNameWithoutExtension( oFile.FileName ) +
"(" + iCounter + ")" +
System.IO.Path.GetExtension( oFile.FileName ) ;
sErrorNumber = "201" ;
}
else
{
oFile.SaveAs( sFilePath ) ;
break ;
}
}
*/
if (this.UserUploadType.ToLower().IndexOf(System.IO.Path.GetExtension(oFile.FileName).ToLower() + ".") > -1)//檢測是否為允許的上傳文件類型
...{
if (this.UserUploadSize * 1024 >= oFile.ContentLength)//檢測文件大小是否超過限制
...{
sFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + System.IO.Path.GetExtension(oFile.FileName);
string sFilePath = System.IO.Path.Combine(sServerDir, sFileName);
oFile.SaveAs(sFilePath);
}
else//文件大小超過限制
...{
Response.Clear();
Response.Write("<script type="text/javascript">");
Response.Write("window.parent.frames['frmUpload'].OnUploadCompleted(1,'上傳文件大小超出限制') ;");
Response.Write("</script>");
Response.End();
}
}
else //文件類型不允許上傳
...{
Response.Clear();
Response.Write("<script type="text/javascript">");
Response.Write("window.parent.frames['frmUpload'].OnUploadCompleted(1,'上傳文件類型不允許') ;");
Response.Write("</script>");
Response.End();
}

}
else
sErrorNumber = "202";
Response.Clear();
Response.Write("<script type="text/javascript">");
Response.Write("window.parent.frames['frmUpload'].OnUploadCompleted(" + sErrorNumber + ",'" + sFileName.Replace("'", "/'") + "') ;");
Response.Write("</script>");
Response.End();
}
最後就是對Uploader.cs類中的OnLoad()函數的修改
protected override void OnLoad(EventArgs e)
...{
// Get the posted file.
HttpPostedFile oFile = Request.Files["NewFile"];
// Check if the file has been correctly uploaded
if (oFile == null || oFile.ContentLength == 0)
...{
SendResults(202);
return;
}
int iErrorNumber = 0;
string sFileUrl = "";
string sFileName = "";
//使用原文件名上傳代碼,如果文件名相同,則在後面加上標號(1)(2)...
/**//*
// Get the uploaded file name.
string sFileName = System.IO.Path.GetFileName( oFile.FileName ) ;

int iCounter = 0 ;
while ( true )
{
string sFilePath = System.IO.Path.Combine( this.UserFilesDirectory, sFileName ) ;
if ( System.IO.File.Exists( sFilePath ) )
{
iCounter++ ;
sFileName =
System.IO.Path.GetFileNameWithoutExtension( oFile.FileName ) +
"(" + iCounter + ")" +
System.IO.Path.GetExtension( oFile.FileName ) ;
iErrorNumber = 201 ;
}
else
{
oFile.SaveAs( sFilePath ) ;
sFileUrl = this.UserFilesPath + sFileName ;
break ;
}
}
*/
//使用原文件名上傳代碼結束
//使用時間作為流水號文件名

if (this.UserUploadSize * 1024 >= oFile.ContentLength)//檢測文件大小是否超過限制
...{
sFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + System.IO.Path.GetExtension(oFile.FileName);
string sFilePath = System.IO.Path.Combine(this.UserFilesDirectory, sFileName);
oFile.SaveAs(sFilePath);
sFileUrl = this.UserFilesPath + sFileName;
}
else//文件大小超過限制
...{
SendResults(1, "", "", "上傳文件大小超出限制");
}
/**//////////////////////////////////////////////////////////////////////////////
SendResults(iErrorNumber, sFileUrl, sFileName);
}
最後只要在Web.Config文件中加入對文件上傳的限制值就可以了.
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="FCKeditor:UserFilesPath" value="/UserFiles/" />
<add key="FCKeditor:UserUploadType" value=".gif.jpg.jpeg.rar.zip.swf.png" />
<add key="FCKeditor:UserUploadSize" value="5120" /><!--單位為KB-->
</appSettings>
<system.web>
<httpRuntime maxRequestLength="512000" />
</system.web>

</configuration>

㈤ fckeditor上傳圖片問題 不能上傳

在FCKEditor2.4.1版在.net環境中圖片上傳的正確配置,以供大家參考,以少走彎路。
asp.net下的fckeditor2.4.1配置
用最簡單的語言描述一下。其它配置和優化就不說了,只說怎麼讓它在asp.net環境下能用,能上傳。
1、下載文件 http://www.fckeditor.net/download
FCKeditor_2.4.1.zip 和 FCKeditor.Net_2.2.zip
這是目前最新的版本。 FCKeditor_2.4.1.zip 為fckeditor的頁面文件 FCKeditor.Net_2.2.zip 是asp.net下的上傳用的 dll控制項和其源文件
2、 解壓FCKeditor_2.4.1.zip 到網站根目錄下的 fckeditor中,解壓FCKeditor.Net_2.2.zip 將其目錄 FCKeditor.Net_2.2\bin\Release中的 FredCK.FCKeditorV2.dll 復制到 根目錄的/bin/下
3、打開/fckeditor/fckconfig.js 修改兩行代碼
var _FileBrowserLanguage = 'aspx' ;
var _QuickUploadLanguage = 'aspx' ;
把默認的asp語言改成aspx
4、這就算行了,開始用吧。根目錄下建立test.aspx,其代碼如下:
<%@ Page language="c#" AutoEventWireup="false" validateRequest=false%>
<%@ Register TagPrefix="FCKeditorV2" Namespace="FredCK.FCKeditorV2" Assembly="FredCK.FCKeditorV2" %>
<form id="Form1" method="post" runat="server">
<FCKeditorV2:FCKeditor id="content" runat="server"></FCKeditorV2:FCKeditor>
</form>
應該就ok了,可以上傳。默認傳到根目錄的/UserFiles/下,不用自己建,它自己會建。
如果要改上傳目錄,需要修改FCKeditor.Net_2.2.zip這個包里的.net源文件。修改FileWorkerBase.cs ,改一下26行
private const string DEFAULT_USER_FILES_PATH = "/UserFiles/" ;
重新編譯一下,生成新的dll,復制過去,應該就OK了。(這個我沒試,應該沒問題)
另外,說一句,fckeditor是很靈活的,可以做很多高級的設置。
還 有的網友,自己優化了它的源文件,有的給它加了功能,比如傳視頻,傳文件什麼的。 但這些修改過的版本,有的是有問題的。 曾經下過一個修改了的2.0 版本, asp下,怎麼設置都上傳不了圖片。 重新下個,隨便設置一下就可以了。所以,還是推薦大家用官方提供的版本。

㈥ fckeditor 怎麼上傳圖片怎麼用

先點擊「上傳」,在上傳的界面選擇需要上傳的文件,然後點擊發送的伺服器,你的「圖像」下的源文件框框自然就有值了,根本不用你輸。
如果你伺服器上已經上傳的有文件了,可以點擊瀏覽伺服器,從中選擇一個文件就可以了,源文件的框框自然就會有值了。
然後再點擊確定就可以了

㈦ java版的fckeditor上傳圖片超過10kb就會提示許可權不足 請問怎麼修改

把他那個幹掉,自己寫個,別人做好的並不一定就是100%可以順心使用!

㈧ fckeditor 編輯器快速上傳圖片

引用:http://student.csdn.net/space.php?uid=53812&do=blog&id=28068
有問題可以和我聊,我也正在研究這個東東

快速上傳:
FCKeditor\editor\filemanager\upload\
asp\
23 ConfigIsEnabled = False
是否啟用快速上傳
27 ConfigUserFilesPath = "/UserFiles/"
如果想上傳到 /test/upload/yyymmdd/的文件夾下面
則修改為 ConfigUserFilesPath = "/test/upload/" & year(now())& right("0"& month(now()),2)&right("0" & day(now()),2)

php與asp 不同的地方
php上傳設置

FCKeditor\editor\filemanager\browser\default\connectors\php下面
config.php

$Config['Enabled'] = true ; 啟用上傳

$Config['UserFilesPath'] = '/test/upload/' ; url顯示出來的路徑,

$Config['UserFilesAbsolutePath'] = 'e:/web/upload' ;伺服器上的真實路徑,建議配置上這個。否則可能出現失去響應的情況

相應文件類型設置:39-40行
connector.php
71行
if ( !in_array( $sResourceType,array('File','Image','Flash','Media') ) )
return ;

]
表示文件類型

快速上傳FCKeditor\editor\filemanager\upload\php
config.php

$Config['Enabled'] = true ;//啟用

// Path to uploaded files relative to the document root.
$Config['UserFilesPath'] = '/test/upload/' ;這是url相對文檔根

$Config['UserFilesAbsolutePath'] = 'e:/web/upload/' ;這才是伺服器上的絕對路徑 建議與上面u那個路徑同時都配置上,如果出現了php上傳沒有反映的問題則可能是這個沒有配置。

㈨ FCKeditor 2.6.4 上傳圖片問題(jsp)(急)

這個問題我也遇到過,可能是許可權的緣故,看看伺服器上的許可權夠不夠。
如果不能解決的話,我推薦你使用另外一種編輯器Ewebeditor,我目前使用這種

熱點內容
LOL腳本識別 發布:2024-05-03 03:53:14 瀏覽:792
祁東福祥惠民卡初始密碼多少 發布:2024-05-03 03:36:02 瀏覽:247
王者什麼東西需要二級密碼 發布:2024-05-03 03:26:11 瀏覽:766
網頁界面升級訪問 發布:2024-05-03 03:26:06 瀏覽:210
安卓區怎麼更改充電提示音 發布:2024-05-03 03:23:56 瀏覽:48
遺傳演算法圖像分割 發布:2024-05-03 03:16:27 瀏覽:801
外圓圓弧怎麼編程 發布:2024-05-03 03:13:59 瀏覽:213
如何在conda中安裝需要編譯的軟體 發布:2024-05-03 02:41:21 瀏覽:780
易語言垃圾清理源碼 發布:2024-05-03 02:40:34 瀏覽:182
滴滴蘋果安卓哪個派單量好 發布:2024-05-03 02:22:52 瀏覽:289