當前位置:首頁 » 文件管理 » kindeditorjava上傳

kindeditorjava上傳

發布時間: 2023-08-13 15:47:56

A. Kindeditor怎麼設置上傳文件的類型和大小啊

以ASP.NET 為例
將下載下來的 編輯器放到根目錄下面

使用編輯器需要首先將LitJSON.dll文件放到bin目錄下面

在examples文件夾下面新建立一個test.aspx

只需設置test.aspx頁面即可

******************************************************test.aspx頁面設置**********************************************

<html>
<head>
<meta charset="utf-8" />
<title>KindEditor ASP.NET</title>
<script charset="utf-8" src="../kindeditor-min.js"></script>
<script charset="utf-8" src="../lang/zh_CN.js"></script>
<script>
KindEditor.ready(function (K) {
K.create('#content', {
uploadJson: '../asp.net/upload_json.ashx',
fileManagerJson: '../asp.net/file_manager_json.ashx',
allowFileManager: true
});
});
</script>
</head>
<body>
<h3>默認模式</h3>
<form id="form1" name="example">
<textarea name="content" id="content" style="width:800px;height:400px;visibility:hidden;">KindEditor</textarea>
<p>
<input type="button" name="getHtml" value="取得HTML" />
<input type="button" name="isEmpty" value="判斷是否為空" />
<input type="button" name="getText" value="取得文本(包含img,embed)" />
<input type="button" name="selectedHtml" value="取得選中HTML" />
<br />
<br />
<input type="button" name="setHtml" value="設置HTML" />
<input type="button" name="setText" value="設置文本" />
<input type="button" name="insertHtml" value="插入HTML" />
<input type="button" name="appendHtml" value="添加HTML" />
<input type="button" name="clear" value="清空內容" />
<input type="reset" name="reset" value="Reset" />
</p>
</form>
</body>
</html>
設置完成後上傳本地文件 注:如在iis下面是用編輯需要設置訪問asp.net文件夾下的許可權許可權

B. kindeditor 怎麼上傳本地視頻,可以在網頁上播放(java

KindEditor上傳的應該是一個embed標簽你可以頁面先獲取kindeditor裡面的內容放在隱藏的div里
<divclass="cont"id="cont"runat="server"style="width:550px;display:none;">
</div>
然後js獲取embed的src
varstr=$(".contembed").first().attr("src");



我是這么寫的 不知道你說的是不是這個意思

C. c#kindeditor編輯器 上傳圖片 要怎麼做

官網都有很詳細的說明文檔呢

KindEditor默認提供ASP、ASP.NET、PHP、JSP上傳程序,這些程序是演示程序,建議不要直接在實際項目中使用。 如果您確定直接使用本程序,使用之前請仔細確認相關安全設置。

//ASP
KindEditor.ready(function(K){
K.create('#textarea_id',{
uploadJson:'../asp/upload_json.asp',
fileManagerJson:'../asp/file_manager_json.asp',
allowFileManager:true
});
});
//ASP.NET
KindEditor.ready(function(K){
K.create('#textarea_id',{
uploadJson:'../asp.net/upload_json.ashx',
fileManagerJson:'../asp.net/file_manager_json.ashx',
allowFileManager:true
});
});
//JSP
KindEditor.ready(function(K){
K.create('#textarea_id',{
uploadJson:'../jsp/upload_json.jsp',
fileManagerJson:'../jsp/file_manager_json.jsp',
allowFileManager:true
});
});

POST參數

imgFile: 文件form名稱

dir: 上傳類型,分別為image、flash、media、file


返回格式(JSON)

//成功時
{
"error":0,
"url":"http://www.example.com/path/to/file.ext"
}
//失敗時
{
"error":1,
"message":"錯誤信息"
}

D. Kindeditor怎麼設置上傳文件的類型和大小

1.頁面代碼
< tr >
< t d >
圖片上傳
< /td >
< td colspan="5" align="left" style="text-align: left;" >
< div id="filediv_infvaluelog_pic" >
< /div >
< input type="button" id="file_btn_infvaluelog_add_pic" value="上傳" />
< /td >
< /tr >
2.腳本代碼
var uploadbutton3 = KindEditor.uploadbutton( {
button : KindEditor('#file_btn_infvaluelog_add_pic'),
fieldName : 'file',
url : 'upload_file_XXX_json?dir=image', //文件上傳的action,設置dir為image
afterUpload : function(data) {
if (data.error === 0) {
//正確的時候執行
} else {
//上傳錯誤後,提示
alert(data.message);
}
},
afterError : function(str) {//沒正確執行時異常
alert('自定義錯誤信息: ' + str);
}
});
uploadbutton3.fileBox.change(function(e) {
uploadbutton3.submit();
});
});
3.action方法
public String fileupload() throws FileNotFoundException{
//最大文件大小
long maxSize = 1000000;
InputStream is = null;
if(imgFile!=null&&imgFile.isFile()){
is = new FileInputStream(imgFile);//傳過來的文件
}else{
if(file.isFile()){
imgFile=file;
imgFileFileName=fileFileName;
is = new FileInputStream(imgFile);//傳過來的文件
}else{
error = 1;
message = "請選擇要上傳的文件。";
}
}
HttpServletRequest request = ServletActionContext.getRequest();
String savePath = null;
String saveUrl = null;
//檢查目錄
File rootDir = new File(savePath);
if(!rootDir.isDirectory()){
error = 1;
message = "上傳根目錄不存在。";
}
//檢查目錄寫許可權
if(!rootDir.canWrite()){
error = 1;
message = "上傳根目錄沒有寫許可權。";
}
String dirName = null;
if (dir == null) {
dirName = "other";
}else{
dirName = dir;
}
//創建文件夾
savePath += "/"+dirName + "/";
saveUrl += "/"+dirName + "/";
File saveDirFile = new File(savePath);
if (!saveDirFile.exists()) {
saveDirFile.mkdirs();
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String ymd = sdf.format(new Date());
savePath += ymd + "/";
saveUrl += ymd + "/";
File dirFile = new File(savePath);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
//檢查文件大小
if(imgFile.length() > maxSize){
error = 1;
message = "上傳文件大小超過限制。";
}else{
//定義允許上傳的文件擴展名
HashMap extMap = new HashMap();
extMap.put("image", "gif,jpg,jpeg,png,bmp");
extMap.put("flash", "swf,flv");
extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb");
extMap.put("file","gif,jpg,jpeg,png,bmp,doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2");

//檢查擴展名
String fileExt = imgFileFileName.substring(imgFileFileName.lastIndexOf(".") + 1).toLowerCase();
if(!Arrays.asList(extMap.get(dirName).split(",")).contains(fileExt)){
error = 1;
message = "上傳文件擴展名是不允許的擴展名。\n只允許" + extMap.get(dirName) + "格式。";
}else{
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "_";
try{
if(imgFileFileName.indexOf(",")!=-1){
imgFileFileName=imgFileFileName.replaceAll(",", "");
}
File deskFile = new File(savePath+newFileName+imgFileFileName);
OutputStream os = new FileOutputStream(deskFile);
byte[] bytefer = new byte[1024];
int length = 0;
while ((length = is.read(bytefer)) != -1) {
os.write(bytefer, 0, length);
}
os.close();
is.close();
error = 0;
//message = "上傳文件成功";
//url = urlRoot + saveUrl + newFileName + imgFileFileName;
if("file".equals(dir)){
url = savePath + newFileName + imgFileFileName;
}else{
url = saveUrl + newFileName + imgFileFileName;
}
url = url.trim().replaceAll("\\\\\\\\", "/");
url = url.replaceAll("\\\\", "/");
//檢查是否是圖片,是才進行壓縮
if(url.endsWith(".jpg")||url.endsWith(".jpeg")||url.endsWith(".png")||url.endsWith(".bmp")||url.endsWith(".gif")){
//壓縮
ImgProce ip = new ImgProce();
ip.setWideth(400);
ip.proce(savePath+newFileName+imgFileFileName, "400");
}
}catch(Exception e){
error = 1;
message = "上傳文件失敗。";
}
}
}
this.map=new HashMap();
this.map.put("error", error);
if(error==0){
this.map.put("url", url);
this.map.put("filename",imgFileFileName);
}else{
this.map.put("message", message);
}
return "SUCCESS";
}

熱點內容
iphone6如何刪除緩存 發布:2025-02-02 08:33:06 瀏覽:829
為什麼路由器的密碼是五位數 發布:2025-02-02 08:32:30 瀏覽:719
怎樣編程選股 發布:2025-02-02 08:22:02 瀏覽:417
電腦web應用伺服器 發布:2025-02-02 08:05:31 瀏覽:811
電腦存儲內存多少合適 發布:2025-02-02 08:00:15 瀏覽:110
登錄界面android 發布:2025-02-02 07:53:23 瀏覽:842
編譯時註解與運行時註解 發布:2025-02-02 07:53:14 瀏覽:818
怎樣登陸ftp 發布:2025-02-02 07:44:44 瀏覽:637
瘋狂點擊腳本 發布:2025-02-02 07:38:10 瀏覽:73
pss演算法 發布:2025-02-02 07:30:55 瀏覽:748