zoukankan      html  css  js  c++  java
  • 文件存入数据库

            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;
            }

  • 相关阅读:
    第4月第1天 makefile automake
    第3月30天 UIImage imageWithContentsOfFile卡顿 Can't add self as subview MPMoviePlayerControlle rcrash
    第3月第27天 uitableviewcell复用
    learning uboot fstype command
    learning uboot part command
    linux command dialog
    linux command curl and sha256sum implement download verification package
    learning shell script prompt to run with superuser privileges (4)
    learning shell get script absolute path (3)
    learning shell args handing key=value example (2)
  • 原文地址:https://www.cnblogs.com/handsomer/p/4117919.html
Copyright © 2011-2022 走看看