你可能在<form encType="multipart/form-data"

解决方案 »

  1.   

    在aspx也面的form后面加上“encType="multipart/form-data"”
      

  2.   

    我觉得好像是从文件读取图像数据!!!
    Stream imgdatastream =File1.PostedFile.InputStream;  出错,可能是因为File1.PostedFile.InputStream语句执行异常,导致imgdatastream没有示例话!!你检查一下File1.PostedFile.InputStream语句的执行,有可能文件的路径没给出,或者没有找到该文件!!可能是这样的,我没有做实验!!!
      

  3.   

    我是用file控件读取jpg文件,然后用button控件触发这段代码,是不是还要写其他代码
      

  4.   

    form 标记的属性<form encType="multipart/form-data" method="post" id="form1" runat="server">
    设置正确了吗?
      

  5.   


    你的对象用的不对!!!看看下面示例是否有启发!!!!
     下面的示例将客户端文件集合中的第一个文件的内容读取到一个字节数组中,并将该字节数组复制到一个字符串。using System.Web;
    HttpFileCollection MyFileCollection;
     HttpPostedFile MyFile;//声明上载文件
     int FileLen;
     System.IO.Stream MyStream;
     
     MyFileCollection = Request.Files;//获得客户端文件集合
     MyFile = MyFileCollection[0];
     
     FileLen = MyFile.ContentLength;
     byte[] input = new byte[FileLen];
     
     // Initialize the stream.
     MyStream = MyFile.InputStream;
     
     MyStream.Read(input, 0, FileLen);//读取文件
     
     // Copy the byte array into a string.
     for (int Loop1 = 0; Loop1 < FileLen; Loop1++)
        MyString = MyString + input[Loop1].ToString();