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