Flex上传图片等信息到数据库,并下载显示图片

context.Response.Write(\失败\); } } } else {

context.Response.Write(\参数错误\); context.Response.End(); } }

public bool IsReusable { get {

return false; } } }

2.读取SqlServer的二进制图片

C#端用FluorineFx.AMF3.ByteArray保存二进制对象,使用Flex端的ByteArray进行接收,并显示在图片中.图片使

用了网友的ByteArrayImage类(继承自mx.controls.Image).

C#端读取数据库记录,将读出的二进制由byte[]转换成ByteArray.

漫画图片实体类 ManHuaTuPian.cs

Code using System;

using System.Collections.Generic; using System.Text; using FluorineFx.AMF3;

namespace ServiceLibrary {

public class ManHuaTuPian {

private int _ID; private int _ManHuaID; private int _JuanShu;

private int _BenJuanTuPianXH; private ByteArray _TuPian;

public int ID { set {

this._ID = value; } get {

return this._ID; } }

public int ManHuaID { set {

this._ManHuaID = value; } get {

return this._ManHuaID;

} }

public int JuanShu { set {

this._JuanShu = value; } get {

return this._JuanShu; } }

public int BenJuanTuPianXH { set {

this._BenJuanTuPianXH = value; } get {

return this._BenJuanTuPianXH; } }

public ByteArray TuPian { set {

this._TuPian = value; } get {

return this._TuPian; } } } }

用于显示二进制图片的组件类 ByteArrayImage ByteArrayImage.as

Code package customComp {

import flash.display.Loader; import flash.events.Event;

import flash.system.LoaderContext; import flash.utils.ByteArray; import mx.controls.Image;

public class ByteArrayImage extends mx.controls.Image {

private var _loader:Loader = new Loader(); public function Image():void {}

override protected function createChildren():void {

addChild(_loader); }

public function loadBytes(bytes:ByteArray,context:LoaderContext=null):void {

_loader.loadBytes(bytes, context);

联系客服:779662525#qq.com(#替换为@)