zoukankan      html  css  js  c++  java
  • GHSpro文件上传

    GHSpro文件上传

    enter description here

    基本设计图

    上传

    上传方式的选择

    采用iframe 的表单上传

    ajaxfileupload

     <div id="step-2" class="step-pane" style="margin:5px">
                <div style="height:40px;line-height:33px;text-align:right">
                    <div class="btn-group">
                        <a id="lr-add-second" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;新增</a>
                        <a id="lr-edit-second" class="btn btn-default"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
                        <a id="lr-delete-second" class="btn btn-default"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
                    </div>               
                </div>
                <table id="gridTable"></table>
              
            </div>
    
      $(function () {
    
            $("#submitId").on("click", function () {
                alert("1")
                ///GetFileEx
                var filePath = $("#file1").val();
                alert(filePath)
                //var fileEx = GetFileEx(filePath);
                var fileNO = "@Run.Util.CommonHelper.CreateNo()";
                if (filePath != null && filePath.length > 0)
                {
                    $.ajaxFileUpload({
                        url: "../../Helper/FileUpload/UpModelWordFile?fileNO=" + fileNO,
                        secureuri: false,//是否启用安全机制
                        fileElementId: 'file1',//file的id
                        dataType: 'application/json',//返回的类型
                        success: function (data) {//调用成功时怎么处理
                            alert(JSON.stringify(data));
                        },
                        error: function (e) { alert(JSON.stringify(e)) }
                    });
                }
                else
                {
                    alert("请先选择文件!");
                }
            });
        });
    

    后台代码

           [HttpPost]
            public ActionResult UpModelWordFile(string fileNO, HttpPostedFileBase file1)
            {
               // string templatePath = Server.MapPath("/") + "Resource/WordTemplate/moban/";
                if (file1.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file1.FileName);
                    var path = Path.Combine(Server.MapPath("~/Resource/WordTemplate/moban"), (fileNO + fileName));
                    file1.SaveAs(path);
                }
                return new ContentResult();           
            }
    
  • 相关阅读:
    安装原版Win8.1并激活
    Java8 List<对象> 转 Set、Map(高级)、排序、分组、统计
    SpringCloud第二弹(高可用Eureka+Ribbon负载均衡)
    SpringCloud第一弹(入门)
    SpringBoot+Shiro+Redis共享Session入门小栗子
    Go语言(IDEA下+Eclipse下)Hello World
    Linux学习杂谈
    小孩儿才分对错,成年人只看利弊
    Xshell5
    91 Testing MySQL学习总结
  • 原文地址:https://www.cnblogs.com/fighter23/p/7873101.html
Copyright © 2011-2022 走看看