码迷,mamicode.com
首页 > 数据库 > 详细

文件存入数据库

时间:2014-11-24 09:58:05      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   os   sp   java   文件   数据   on   

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

文件存入数据库

标签:http   io   ar   os   sp   java   文件   数据   on   

原文地址:http://www.cnblogs.com/handsomer/p/4117919.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!