日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

xheditor开源编辑器ajax上传功能的完善

發布時間:2025/4/16 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 xheditor开源编辑器ajax上传功能的完善 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

編輯器很多大家肯定都不陌生,有名的fckeditor,ewebeditor...
這年頭倒霉的事都輪到我了,前不久我用aspx寫了個網站,也是幫學校寫的,關鍵是網絡辦老師郁悶,由于我用的是fckeditor,可是他非說這個東西有漏洞,于是我去網上找了些資料,哪個編輯器沒漏洞啊,我對老師無語啊,可能前不久我們學校網站被黑,老師慌了,他就是不讓我上傳...于是我就尋思著換個編輯器,那就搞個無名的,開源的,找來找去找到了xheditor,這個編輯器確實也可以,調用方便,不用改代碼很多,在aspx下就OK搞定,但這種開源的東西功能上肯定不過關啊,其中一個就是上傳,也就這個東西最關鍵。
官網上的最新版本就有一個php的開發版本(支持ajax上傳的),現在我要做的就是:對xheditor寫個在aspx下上傳的功能
xheditor的下載地址:http://code.google.com/p/xheditor/downloads/list

下面是編輯器的界面:

upload.aspx頁面代碼:

?

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class admin_Upload : System.Web.UI.Page
{
??? protected void Page_Load(object sender, EventArgs e)
??? {
??????? FileUpload.FileUpLoad fp = new FileUpload.FileUpLoad();
??????? fp.FilePath = "upload";

??????? Response.Write(fp.uploadFile(Request.Files["upload"]));
??? }
}

?

?

FileUpload.cs:

?

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;

/// <summary>
///FileUpload 的摘要說明
/// </summary>
public class FileUpload
{
??? public class FileUpLoad
??? {
??????? private string fileExtension;


??????? /// <summary>
??????? /// 上傳文件路徑
??????? /// </summary>
??????? public string FilePath
??????? {
??????????? get
??????????? {
??????????????? return filepath;
??????????? }
??????????? set
??????????? {
??????????????? filepath = value;
??????????? }
??????? }
??????? private string filepath;


??????? public string uploadFile(HttpPostedFile postedFile)
??????? {

??????????? string fileName = Path.GetFileName(postedFile.FileName);
??????????? string fileExtension = Path.GetExtension(postedFile.FileName);
??????????? string phyPath = HttpContext.Current.Request.MapPath(FilePath);

??????????? DirectoryInfo upDir = new DirectoryInfo(phyPath);
??????????? //判斷上傳路徑是否存在,不存在則創建
??????????? if (!upDir.Exists)
??????????? {
??????????????? upDir.Create();
??????????? }
??????????? //保存文件
??????????? try
??????????? {
??????????????? postedFile.SaveAs(phyPath + "\\" + fileName);
??????????????? return "{err:\"\",msg:\"../" + FilePath + "/" + fileName + "\"}";
??????????? }
??????????? catch (Exception e)
??????????? {
??????????????? throw new ApplicationException(e.Message);
??????????? }

??????? }
??? }
}

希望廣大的高手繼續更新完善...把這個接口做得更好!

?

轉載于:https://www.cnblogs.com/zhulidong/archive/2009/11/01/1593880.html

總結

以上是生活随笔為你收集整理的xheditor开源编辑器ajax上传功能的完善的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。