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

phpckeditor上傳圖片

發布時間: 2022-08-03 19:50:21

A. ckeditor 上傳圖片 php

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

B. ckeditor5上傳的圖片如何用PHP接收

從圖上看應該是傳的文件用$_FIELES接收,
如果不行的話試試用file_get_contents('php://input');試試

C. 怎麼為ckeditor添加圖像

為ckeditor添加圖像的方法
1. 到官網下載ckeditor
2. 復制到java web項目目錄下
3. 配置config文件,打開圖片上傳功能

CKEDITOR.editorConfig = function (config) {
// 換行方式
config.enterMode = CKEDITOR.ENTER_BR;
// 當輸入:shift+Enter是插入的標簽
config.shiftEnterMode = CKEDITOR.ENTER_BR;//
//圖片處理
config.pasteFromWordRemoveStyles = true;
config.filebrowserImageUploadUrl = "ckUploadImage.action?type=image";

// 去掉ckeditor「保存」按鈕
config.removePlugins = 'save';
};

4. java後台處理代碼
// 上傳圖片
@Action(value = "/ckUploadImage", results = { @Result(name = "success", location = "/upload.jsp") })
public String uploadImages() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
FileOutputStream fos;
String webRoot = request.getSession().getServletContext().getRealPath(
"");
// 獲取圖片後綴名
String partRightType = uploadFileName.substring(uploadFileName
.lastIndexOf("."));
String CKEditorFuncNum = request.getParameter("CKEditorFuncNum");
// 判斷圖片的格式
if (!ImageFile.checkImageType(partRightType)) {
String path = "";
String alt_msg = "Sorry! Image format selection is incorrect, please choose GIF, jpeg, PNG format JPG, picture!";
pringWriterToPage("<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction("
+ CKEditorFuncNum
+ ", '"
+ path
+ "' , '"
+ alt_msg
+ "');</script>");
} else {
try {
uploadFileName = DateUtils.getDateNoStyle() + "-"
+ UUID.randomUUID() + partRightType;
String savePath = webRoot + Constants.UPLOAD_IMAGES_PATH;
File uploadFilePath = new File(savePath);
if (uploadFilePath.exists() == false) {
uploadFilePath.mkdirs();
System.out.println("路徑不存在,但是已經成功創建了" + savePath);
} else {
System.out.println("路徑存在了" + savePath);
}
fos = new FileOutputStream(new File(savePath + uploadFileName));
FileInputStream fis = new FileInputStream(getUpload());
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
fos.close();
fis.close();
} catch (FileNotFoundException foe) {
System.out.println("上傳文件為0位元組");
}
// String path = "http://" + request.getServerName() + ":"
// + request.getServerPort() + request.getContextPath()
// + Constants.UPLOAD_IMAGES_PATH + uploadFileName;
String path = request.getContextPath()
+ Constants.UPLOAD_IMAGES_PATH + uploadFileName;
String alt_msg = "";
pringWriterToPage("<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction("
+ CKEditorFuncNum
+ ", '"
+ path
+ "' , '"
+ alt_msg
+ "');</script>");
}
return null;
}

* 其實重點的代碼就是這點
pringWriterToPage("<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction("
+ CKEditorFuncNum
+ ", '"
+ path
+ "' , '"
+ alt_msg
+ "');</script>");

D. 你好,我想知道ckeditor3.6以上的在配置上傳圖片的時候,都要接受哪些參數啊,參數名是什麼,

上傳的表單名叫 upload, $_FILES['upload']

上傳成功後輸出:
echo '<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction('
.$_GET['CKEditorFuncNum'].', \'文件路徑\', \'失敗顯示的消息,成功就為空\');</script>'

E. 接續CKEditor如何上傳圖片配置PHP語言_PHP教程

可以發送到新浪微博。跟大家分享,希望官方能及早開放API。誕生更多應用. 以下為引用的內容: ?php /* -------------------------------------------------------CKEditor的原包中沒有包含圖片的上傳伺服器端處理文件,其公司的另一款開源產品:CKFinder做了很好的補充。但是要下載這個源代碼再進行配置,雖然方便了很多,但是僅僅為了上傳圖片,卻要使用這么大的整個系統來使用,確實有點大材小用,我花了一個下午的時間,自己用PHP腳本寫了一個處理上傳文件的腳本代碼,沒有做更多的安全處理,希望對大家有用。首先,在你的config.js文件里添加如下代碼:以下為引用的內容:CKEDITOR.editorConfig = function( config ){config.filebrowserImageUploadUrl = './upload.php?type=img';
config.filebrowserFlashUploadUrl = './upload.php?type=flash';
$config['flash']=array("flv","swf"); //flash允許後綴$config['flash_size']=200; //上傳flash大小上限 單位:KB
$config['img_size']=500; //上傳img大小上限 單位:KB$config['message']="上傳成功"; //上傳成功後顯示的消息,若為空則不顯示$config['name']=mktime(); //上傳後的文件命名規則 這里以unix時間戳來命名$config['flash_dir']="/ckeditor/upload/flash"; //上傳flash文件地址 採用絕對地址 方便upload.php文件放在站內的任何位置 後面不加"/"
$config['img_dir']="/ckeditor/upload/img"; //上傳img文件地址 採用絕對地址 採用絕對地址 方便upload.php文件放在站內的任何位置 後面不加"/"$config['site_url']=""; //網站的網址 這與圖片上傳後的地址有關 最後不加"/" 可留空//文件上傳
uploadfile();function uploadfile(){global $config;
//判斷是否是非法調用
if(empty($_GET['CKEditorFuncNum']))
mkhtml(1,"","錯誤的功能調用請求");
$fn=$_GET['CKEditorFuncNum'];
if(!in_array($_GET['type'],$config['type']))
mkhtml(1,"","錯誤的文件調用請求");
$type=$_GET['type'];
if(is_uploaded_file($_FILES['upload']['tmp_name'])){//判斷上傳文件是否允許
$filearr=pathinfo($_FILES['upload']['name']);
$filetype=$filearr["extension"];
if(!in_array($filetype,$config[$type]))
mkhtml($fn,"","錯誤的文件類型!");
//判斷文件大小是否符合要求
if($_FILES['upload']['size']>$config[$type."_size"]*1024)
mkhtml($fn,"","上傳的文件不能超過".$config[$type."_size"]."KB!");

F. php ckeditor 圖片上傳錯誤

你要把報錯信息列印出來才能知道怎麼解決啊,ckeditor最常見的報錯是許可權問題,是不是你要上傳的那個文件夾不存在或者沒有許可權?

G. 誰能告訴我怎樣在ASP CKEditor 中實現上傳圖片功能

1、項目先新建Lbrary文件夾跟js文件夾(js小寫)並在js文件夾下,在簡歷ckeditor和ckfinder文件夾,壓縮包找到其中/bin/Debug下的CKEditor.NET.dll考到新建的文件夾下,如後在引用中右鍵添加對剛才的CKEditor.NET.dll的引用,如圖:

H. ckeditor上傳圖片php 網上垃圾信息好多都是復制的沒用求解答

其實簡單來說,不管用什麼語言,ckeditor上傳(不管圖片還是其他文件)只要注意三點:
一、config裡面設置上傳路徑
oCKeditor.config.filebrowserBrowseUrl = 對應的文件瀏覽頁面;
oCKeditor.config.filebrowserImageBrowseUrl = 對應的圖片瀏覽頁面;
oCKeditor.config.filebrowserFlashBrowseUrl = 對應的flash瀏覽頁面;
oCKeditor.config.filebrowserUploadUrl = 對應的文件上傳頁面;
oCKeditor.config.filebrowserImageUploadUrl = 對應的圖片上傳頁面;
oCKeditor.config.filebrowserFlashUploadUrl = 對應的flash上傳頁面;
二、上傳後(或瀏覽已上傳文件並選擇後)的文件參數的回傳
ckeditor在提交上傳時會自動提交一個CKEditorFuncNum的參數,這是ckeditor的回傳函數排序號,可以通過window.parent.oCKeditor.tools.callFunction( funcNum, fileUrl, data )回傳文件路徑和附件信息(data包括錯誤碼),這些可以在上傳頁面通過輸出javascript代碼實現。
當然,如果你不滿足僅僅將文件參數回傳給ckeditor,你可以額外增加其他代碼,或通過前置定義重定義ckeditor的回傳函數,代碼可參考如下:
var oCKeditor = CKEDITOR.replace(editorName(你定義的ckeditor的名稱));
oCKeditor.on( 'instanceReady', function( event )
{
var editor = event.editor;
setTimeout( function()
{
if ( !editor.element )
{
setTimeout( arguments.callee, 100 );
return;
}
event.removeListener( 'instanceReady', this.callee );
if ( editor.name == editorName(你定義的ckeditor的名稱) )
{
var bFilebrowserFn = editor._.filebrowserFn;
var setUploadFileck=function(a,b){CKEDITOR.tools.callFunction(bFilebrowserFn, a, b);此處可編寫自定義文件上傳後頁面交互,可將文件路徑提交給某一input};
editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUploadFileck, editor );
}
}, 0 );
}, null, null, 9999);
三、就是頁面編碼問題,防止上傳後中文文件名出現亂碼,這個我就不累述啦。

希望對你有所幫助。

I. ckeditor+php多圖片上傳問題。

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

J. CKEditor+CKFinder,上傳圖片成功,圖片鏈接正確,但是無法顯示,請問怎麼回事

1,將ckeditor解壓打開,打開_Samples,將ckeditor文件夾拷貝項目中的根目錄下,把bin放在根目錄下

2,將ckfinder解壓,ckfinder文件夾拷貝項目中的根目錄下,把bin放在根目錄下,把_sample,_source,help文件夾刪除掉,(註:沒有用)

3,在ckeditor文件下找到config.js 打開,找到
在CKEDITOR.editorCongig=function(config)
{
//填寫以下內容,圖片,flash路徑
config.uiColor = '#F7F8F9'
config.scayt_autoStartup = false
config.language = 'zh-cn'; //中文
config.filebrowserBrowseUrl = 'ckfinder/ckfinder.html';
config.filebrowserImageBrowseUrl = 'ckfinder/ckfinder.html?Type=Images';
config.filebrowserFlashBrowseUrl = 'ckfinder/ckfinder.html?Type=Flash';
config.filebrowserUploadUrl = 'ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files';
config.filebrowserImageUploadUrl = 'ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images';
config.filebrowserFlashUploadUrl = 'ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash';
};

4,在ckfinder文件下找到config.ascx文件,打開
1)把public overrider bool ChekcAuthentication(){return false;改為:return true;}
2)public overrider void SetConfig(){BaseUrl = "~/ckfinder/userfiles/";}

5,在頁面中head標簽內寫入:
<script type="text/javascript" src="ckeditor/ckeditor.js" ></script>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
如果有母版頁,在母版頁中寫
--註:單純的配置,6,7可以不要,但是一旦要入資料庫中,就要配置6.7步驟

6,在Default.aspx頁面中,寫入<%@Page ValidateRequest="false"%>

7,在web.config文件中,在system.web下寫 <httpRuntime requestValidationMode="2.0"/>

8,在Default.aspx頁面中添加<asp:TextBox ID="txtcontent" runat="server" TextMode="MultiLine" Height="503px" Width="100%" class="ckeditor" ></asp:TextBox>
<script type="text/javascript">
CKEDITOR.replace('<%= txtcontent.ClientID %>', { skin: 'kama' });
</script>(用ckfinder文件下skins文件下kama文件下的,skin.js,樣式)

熱點內容
scratch少兒編程課程 發布:2025-04-16 17:11:44 瀏覽:642
榮耀x10從哪裡設置密碼 發布:2025-04-16 17:11:43 瀏覽:368
java從入門到精通視頻 發布:2025-04-16 17:11:43 瀏覽:89
php微信介面教程 發布:2025-04-16 17:07:30 瀏覽:312
android實現陰影 發布:2025-04-16 16:50:08 瀏覽:794
粉筆直播課緩存 發布:2025-04-16 16:31:21 瀏覽:347
機頂盒都有什麼配置 發布:2025-04-16 16:24:37 瀏覽:213
編寫手游反編譯都需要學習什麼 發布:2025-04-16 16:19:36 瀏覽:818
proteus編譯文件位置 發布:2025-04-16 16:18:44 瀏覽:369
土壓縮的本質 發布:2025-04-16 16:13:21 瀏覽:596