• 文件存入数据库


            function ajaxFileUpload() {
                var File_box = document.getElementById('Download_file');
                //var extend = File_box.value.substring(File_box.value.lastIndexOf(".") + 1);
                if (File_box.value == "" || File_box.value == null) {
                    alert('请先选择文件!');
                }
                else {
                    $.ajaxFileUpload({
                        url: 'Download_Manage_Api.ashx?act=file',
                        secureuri: false,
                        fileElementId: 'Download_file',
                        dataType: 'json',
                        success: function (data, status) {
                            FileSrc = data[1];
                            alert(data[0] + '上传成功');
                            $("#FileUploadDiv").css("display", "none");
                            $("#FileLabel").css("display", "block");
                        }
                    });
                }
            }

    <script src="../Scripts/ajaxfileupload.js" type="text/javascript"></script>
    <script src="../Scripts/easyui/jquery.easyui.min.js" type="text/javascript"></script>

    api
                    //获取前台传来的文件
                    HttpFileCollection files = HttpContext.Current.Request.Files;
                    Stream st = files[0].InputStream;
                    byte[] bytes = new byte[st.Length];
                    st.Read(bytes, 0, bytes.Length);
                    st.Close();
                    string result = "[" + """ + BLLPro.InsertFJ(bytes) + ""]";
                    context.Response.Write(result);

    dal
            public string InsertFJ(byte[] file)
            {
                string JID = Guid.NewGuid().ToString("N");
                string sql = "insert into jhac_tb_product_fj (JID,PDC_FJ) values (:JID,:PDC_FJ)";
                OracleParameter[] parameters = {
    new OracleParameter(":JID", OracleType.VarChar,400),
    new OracleParameter(":PDC_FJ", OracleType.Blob)
    };
                parameters[0].Value = JID;
                parameters[1].Value = file;
                DbHelperOra.ExecuteSql(sql, parameters);
                return JID;
            }

  • 相关阅读:
    ifelse选择结构
    Chrome插件开发进阶
    java应用线上一次故障诊断分析
    阻止保存要求重新创建表的更改
    【设计模式系列】行为型模式之Mediator模式
    C#.NET第一阶段课件下载
    Unity Animation.CrossFade Animation.Play
    Unity Resources.Load
    Unity Transform
    VS Ctrl + Shift + Q
  • 原文地址:https://www.cnblogs.com/handsomer/p/4117919.html
Copyright © 2020-2023  润新知