传一个vc++ Post文件的类

参照网上资料根据自己需求修改的一个vcActiveX与asp.net页面文件交互传输文件的类部分(不可传输大文件)

1.vc中导入头文件和cpp文件

2.vc中使用

 UpLoadFile *  upfile = new  UpLoadFile;
 upfile
-> Upload( " D:\\ClassDiagram1.bmp " , " localhost " , " 80 " , " /WebApplication1/Default.aspx " );

3.aspx接收处理端Page_Load中

ContractedBlock.gif ExpandedBlockStart.gif Code
 1            IServiceProvider provider = ( IServiceProvider )HttpContext.Current;
 2            HttpWorkerRequest request = ( HttpWorkerRequest )provider.GetService( typeof( HttpWorkerRequest ) );
 3            byte[] byteHeader = request.GetPreloadedEntityBody();
 4            if ( byteHeader != null )
 5ExpandedBlockStart.gifContractedBlock.gif            {
 6                byte[] byteData = new byte[request.GetTotalEntityBodyLength()-byteHeader.Length];
 7                int size = request.ReadEntityBody( byteData , 0 , byteData.Length );
 8
 9                byte[] theImgData = new byte[byteHeader.Length + byteData.Length + 1];
10
11                for ( int i = 0 ; i < byteHeader.Length ; i++ )
12                    theImgData[i] = byteHeader[i];
13
14                for ( int i = 0 ; i < byteData.Length ; i++ )
15                    theImgData[byteHeader.Length + i] = byteData[i];
16
17                using ( MemoryStream mStream = new MemoryStream( theImgData ) )
18ExpandedSubBlockStart.gifContractedSubBlock.gif                {
19                    System.Drawing.Image img = System.Drawing.Image.FromStream( mStream );
20                    img.Save( "D:\\test\\aaa.bmp" , System.Drawing.Imaging.ImageFormat.Bmp );
21                    img.Dispose();
22                }

23            }

 

注:  以上代码在 vc++6.0和vs05 iis6 win03上测试通过 ( 附件是vc UpLoadFile类 )

vc_Upload

转载于:https://www.cnblogs.com/nic_gz/archive/2009/06/10/1500957.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值