EXT前端页面代码如下 请求一个页面进行动态图片加载
{
fieldLabel: '头像',
style:'margin-left:10px',
html: '<iframe id="framePic" src="" width="150" height="100" frameborder="0" scrolling="no" frameborder="0"></iframe>',
autoScroll: true,
}
上传的文本如下
{
xtype: 'textfield',
id: 'imgFileEidt',
name: 'imgFileEidt',
inputType: "file",
labelWidth: 60,
fieldLabel: '上传照片',
listeners: {
'change': function () {
}
},
msgTarget: 'under',
validator: function (value) {
var panduan = value.split('.');
if (panduan[panduan.length - 1] == 'jpg' || panduan[panduan.length - 1] == '') {
return true;
}
else {
return "上传文件必须是jpg, jpeg类型文件中的一种!";
}
}
}
请求的iframe页面如下显示,数据库中存储的为图片的二进制格式,从数据库中读取图片的二进制格式,将其转换,数据库中的存储类型为blob类型存储。
public partial class ShowPic : System.Web.UI.Page
{
protected string DbConnction = DEncryptHelper.Decrypt(SystemConfig.GetParam(CommonConst.COM_DB_CON_KEY));
protected void Page_Load(object sender, EventArgs e)
{
string login_name = Request["login_name"].ToString();
OraDBHelper db = new OraDBHelper(DbConnction);
byte[] pic = null;
try
{
db.Open();
List<OracleParameter> paramList = new List<OracleParameter>();
paramList.Add(new OracleParameter(":login_name", login_name));
DataTable dt = db.ExecuteQuery("select PHOTO from ldata.AP_USER_T WHERE login_name=:login_name", paramList);
if (dt != null && dt.Rows.Count > 0)
{
pic = (byte[])dt.Rows[0]["PHOTO"];
}
}
catch (Exception)
{
}
if (pic != null)
{
Bitmap bitMap = null;
MemoryStream stream = new MemoryStream();
//string PATH = "../Photo/";
Random R = new Random();
string RES= R.Next(0, 9999).ToString();
RES += ".jpg";
//string fullName = PATH + "default.jpg";
//string fullName = PATH + RES;
stream.Write(pic, 0, pic.Length);
bitMap = new Bitmap(stream);
Response.ContentType = "image/Jpeg";
bitMap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
}
}
上面的代码直接将转换完成的图片在页面输出