日期:2014-05-17  浏览次数:20932 次

ASP环境,百度Ueditor 无法上传附件,提示405错误或者404错误解决办法。

UEditor是由百度web前端研发部开发所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点,开源基于BSD协议,允许自由使用和修改代码...

在Ueditor1.2.0.0和之前的版本都支持asp,但是附件上传是无法使用的,通过查看代码后发现,Ueditor根本就没有提供asp环境下的附件上传功能,百度这么大的公司也有不厚道的时候,难道Ueditor开发组是为了从安全角度考虑而放弃了这个功能?不管什么原因,只好自己弄一个,解决办法如下:

1、找到Ueditor所在目录下的dialogs\attachment\attachment.html,打开后找到里面的

upload_url:"../../server/upload/php/fileUp.php"

改为:

upload_url:"../../server/upload/asp/FileUp.asp"

附上attachment.html文件,如果你找不到attachment.html文件,那就Copy一下吧,内容如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>附件上传</title>
    <meta http-equiv="Content-Type" content="text/html;charset=gbk"/>
    <link rel="stylesheet" type="text/css" href="attachment.css"/>
</head>
<body>
<div class="wrapper">
    <div class="controller">
        <span id="divStatus">本次共成功上传 0 个文件</span>
        <span id="spanButtonPlaceHolder"></span>
    </div>
    <div class="fieldset flash" id="fsUploadProgress"></div>
    <span id="startUpload" style="display: none;"></span>

</div>
<script type="text/javascript" src="../internal.js"></script>

<script type="text/javascript" src="../../third-party/swfupload/swfupload.js"></script>
<script type="text/javascript" src="../../third-party/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="../../third-party/swfupload/fileprogress.js"></script>
<script type="text/javascript" src="callbacks.js"></script>
<script type="text/javascript" src="fileTypeMaps.js"></script>
<script type="text/javascript">
    var swfupload,
        filesList=[];
    window.onload = function () {
        var settings = {
            flash_url:"../../third-party/swfupload/swfupload.swf",
            flash9_url:"../../third-party/swfupload/swfupload_fp9.swf",
            upload_url:"../../server/upload/asp/FileUp.asp",           //附件上传服务器地址
            post_params:{"PHPSESSID":"<?php echo session_id(); ?>"}, //解决session丢失问题
            file_size_limit:"100 MB",                                 //文件大小限制,此处仅是前端flash选择时候的限制,具体还需要和后端结合判断
            file_types:"*.*",                                         //允许的扩展名,多个扩展名之间用分号隔开,支持*通配符
            file_types_description:"All Files",                      //扩展名描述
            file_upload_limit:100,                                   //单次可同时上传的文件数目
            file_queue_limit:10,                                      //队列中可同时上传的文件数目
            custom_settings:{                                         //自定义设置,用户可在此向服务器传递自定义变量
                progressTarget:"fsUploadProgress",
                startUploadId:"startUpload"
            },
            debug:false,

            // 按钮设置
            button_image_url:"../../themes/default/images/fileScan.png",
            button_width:"100",
            button_height:"25",
            button_placeholder_id:"spanButtonPlaceHolder",
            button_text:'<span class="theFont">文件浏览…</span>',
            button_text_style:".theFont { font-size:14px;}",
            butt