当前位置:首页 » 文件管理 » 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";
}

热点内容
l2l3缓存 发布:2025-02-02 06:56:47 浏览:521
为什么安卓下不了虫虫助手 发布:2025-02-02 06:46:47 浏览:41
ftp服务器ui 发布:2025-02-02 06:24:15 浏览:102
wifi有多少种密码 发布:2025-02-02 06:22:06 浏览:586
app账号和密码忘了怎么办啊 发布:2025-02-02 06:21:58 浏览:105
map访问 发布:2025-02-02 06:09:07 浏览:825
android获取应用版本 发布:2025-02-02 05:54:19 浏览:747
pythonif比较 发布:2025-02-02 05:24:03 浏览:260
已连接的无线网如何知道密码 发布:2025-02-02 04:53:51 浏览:634
android编程入门经典pdf 发布:2025-02-02 04:46:19 浏览:59