<%
formSize=Request.TotalBytes() 
        formData=Request.BinaryRead(formSize) 
        DataHeader=LeftB(formData,InStrB(formData,Chrb(13)&Chrb(10))) 
        strFileData=MIDB(formData,LenB(DataHeader),LenB(formData)-LenB(DataHeader)*2-3) 
        HeaderPos2=InStrB(strFileData,ChrB(AscB("-"))&ChrB(AscB("T"))&ChrB(AscB("y"))&ChrB(AscB("p"))&ChrB(AscB("e"))) 
        HeaderPos3=InStrB(HeaderPos2,strFileData,Chrb(13)) 
        DataHeader2=LeftB(strFileData,HeaderPos3+4) 
        strFileData=MIDB(strFileData,LenB(DataHeader2),LenB(strFileData)) 
        Response.binaryWrite(strFileData)
%>
在Asp时代以上这段代码是用来保存流的数据文件的,请问在.NET下这段代码应该是怎么去实现的,超急啊
我要实现这样的功能.Upload.htm-->Upload.aspx保存图片....大家帮忙一起看看了.谢谢啊.分不够可以另外开贴给分..

解决方案 »

  1.   

    http://tech.2ec.cn/web/9.shtm 你看看吧
      

  2.   

    asp不懂,你是想要保存图片吗?
      

  3.   

    用<input type="file" ... runat=server>
      

  4.   

    谢谢楼上的朋友们。
    我想要实现这样的效果,A.htm-->A.Aspx保存,所以Yellow198267的那样加runat="server"看来是行不通的。
    目前可以实现的只能通过:        
    Byte[] _Byte=Request.BinaryRead(Request.TotalBytes);
    Response.BinaryWrite(_Byte);
    但是问题是这样获得的数据中,会包含很多垃圾文件信息,比如上传的时候是图片保存的时候,图片就不对了。
    这个改如何解决啊,超急啊,今天一定要解决的。最后一天了,谢谢大家先了。分不够,开贴另外给。
      

  5.   

    到asp.net上搜一下“上传文件".
      

  6.   

    转为byte类型后存入Image字段。
    byte[] imagebytes=null;
    FileStream fs=new FileStream(Image_path,FileMode.Open);
    BinaryReader br=new BinaryReader(fs);
    imagebytes=br.ReadBytes(br.Length);
    SqlParameter parInput22=cmd.Parameters.Add("@员工图片",SqlDbType.Image);
    parInput22.Direction=ParameterDirection.Input;
    cmd.Parameters["@员工图片"].Value=imagebytes;
    cmd.ExecuteNonQuery();
    数据库中操作图片
    How To Read and Write BLOB Data by Using ADO.NET with Visual C# .NET
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;309158
    DataGrid显示图片(物理路径式和Stream流式)和添加图片到数据库
    http://singlepine.cnblogs.com/articles/288027.html