zoukankan      html  css  js  c++  java
  • ASP.NET配置Ueditor编辑器上传图片路径

    1、配置ueditor/editor_config.js文件,将

            //图片上传配置区
            ,imageUrl:URL+"net/imageUp.ashx"             //图片上传提交地址
            ,imagePath:URL + "net/"                     //图片修正地址,引用了fixedImagePath,如有特殊需求,可自行配置

    修改为

            //图片上传配置区
            ,imageUrl:URL+"net/imageUp.ashx"             //图片上传提交地址
            ,imagePath:"http://localhost:3499/"                     //图片修正地址,引用了fixedImagePath,如有特殊需求,可自行配置

    说明:其实,这里唯一变的地方就是imagePath,因为URL的值是通过一个函数计算出来的,其默认是就是ueditor所在的网页路径,比如:http://www.a.com/ueditor/。如果imagePath不做修改的话,那么我们在上传完图片,点击确定之后,编辑器返回的图片路径就是http://www.a.com/ueditor/net/upload/xxxxx.jpg。但是我们不想保存在/ueditor/net/upload/目录下,我们只想保存在根目录下面的upload下面,怎么办?那我们只要修改imagePath的值就可以了。就像上面一样。

    2、修改ueditor/net/imageUp.ashx文件,将文件头部的

    <%@ Assembly Src="Uploader.cs" %>

    去掉。如果不去掉,就会提示:网络链接错误,请检查配置后重试。在网上查了下原因,说是跟.NET Framework版本有关。我的是4.0的。

    3、修改ueditor/net/Uploader.cs文件,将

            pathbase = pathbase + DateTime.Now.ToString("yyyy-MM-dd") + "/";
            uploadpath = cxt.Server.MapPath(pathbase);//获取文件上传路径

    修改为

            pathbase = pathbase + DateTime.Now.ToString("yyyy-MM-dd") + "/";
            uploadpath = cxt.Server.MapPath("~/" + pathbase);//获取文件上传路径

    说明:因为这里的pathbase的值是“upload/”,我们获取文件上传路径的值就是:http://www.a.com/ueditor/net/upload/,不是我们想要的结果,所以我在这里加了个定位到网站根目录的字符串。这样uploadpath返回的值就是正确的了:http://www.a.com/upload/。

    4、在页面上添加代码,显示ueditor。

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Ueditor.aspx.cs" Inherits="WebForm.Ueditor" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript" src="ueditor/ueditor.config.js"></script>
        <script type="text/javascript" src="ueditor/ueditor.all.min.js"></script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <script id="myEditor" type="text/plain" name="content"></script>
        </div>
        </form>
    </body>
    </html>
    <script type="text/javascript">
        //创建编辑器
        var editor = new UE.ui.Editor({ initialFrameWidth: 600, initialFrameHeight: 300 });
        editor.render("myEditor");
    </script>

    仅供参考。

    其实,我们只要调试下就可以解决上传路径的问题。很简单的。

  • 相关阅读:
    【Silverlight】Bing Maps学习系列(八):使用Bing Maps Silverlight Control加载自己部署的Google Maps
    Visual Studio 2010在简洁中强调团队合作
    【Silverlight】Bing Maps学习系列(九):自定义功能导航条(Custom NavigationBar)
    Flash OBJECT 和 EMBED 标签
    SWFObject 的原站提供的使用说明
    一篇清楚阐述 JAvaScript 传递数据 到 Flash 的文章
    Flare 的 Edge边上加 Label
    借助 SWFObject 实现利用JavaScript嵌入 Flash
    3种基本的Flash/Javascript通信方式 (转)
    passing data from HTML to Flash
  • 原文地址:https://www.cnblogs.com/subendong/p/3227463.html
Copyright © 2011-2022 走看看