我有些资料,是关于HTTP上传图片的原理,不知道能不能帮到你什么,^_^
如下:1、图片提交(client,HTML)
<html><body><form ation="upload.asp" method="post" enctype="multipart/form-data">
<input name="pic" type="file" id="pic"><br>
<input type="submit" name="Submit" value="提交">
</form></body></html>2、图片接收(server,ASP)
<% 
  function StringToBinary(String)’自定义函数,将字符串转化为二进制。 
    Dim i, b 
    For i=1 to len(String) 
      b = b & ChrB(Asc(Mid(String,i,1))) 
    Next  
    StringToBinary = b 
  End function 
  data=Request.BinaryRead(request.TotalBytes)’从客户端读取所有数据 
  ct=Request.Servervariables("HTTP_Content_Type") 
  Boundary ="--"&Mid(ct, InStr(LCase(ct), "boundary=") + 9) 
  str2=StringToBinary("image/bmp") 
  start=instrb(data,str2)+13’图片信息的开始字节 
  if start=13 then 
    str2=StringToBinary("image/gif") 
    start=instrb(data,str2)+13 
  end if 
  if start=13 then 
    str2=StringToBinary("image/pjpeg") 
    start=instrb(data,str2)+15 
  end if 
  str3=StringToBinary(Boundary) 
  tend=instrb(10,data,str3)’图片信息的结束字节 
  leng=tend-start’图片信息的长度 
  rdata=midb(data,start,leng)’取出图片信息  ……%>

解决方案 »

  1.   

    试一试用Web Servicehttp://dotnet.aspx.cc/ShowDetail.aspx?id=6381BD5F-51F3-4339-4239-1328564A1B2A
      

  2.   

    do you need to set a proxy? if not, you can use System.Net.WebClient class, otherwise, use System.Net.HttpWebRequest class, seeRetrieving HTTP content in .NET
    http://www.west-wind.com/presentations/dotnetWebRequest/dotnetWebRequest.htm
    there is a section on how to upload files
      

  3.   

    你查一下 httpresponse 与 httprequest 类,好像这两个类是可以的
      

  4.   

    要上传到外网服务器!
    访问外网服务器时。外网服务器网站有上传功能就行了!
    选择附件: 
    <input id="upload" style="WIDTH: 360px; HEIGHT: 22px" type="file" size="56" name="upload"  class="edline" runat="server">
    后台:
    private void iBtnOk_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
    int FileLength=0;
    System.Web.HttpPostedFile UpFile=upload.PostedFile ;
    FileLength=UpFile.ContentLength ;
    string strFileName= UpFile.FileName.Substring(UpFile.FileName.LastIndexOf("\\")+1);

    byte[] FileData=new byte[FileLength];
    if (FileLength!=0)
    { System.IO.Stream FileStream=UpFile.InputStream;
    FileStream.Read(FileData ,0,FileLength );//读入文件
    }
        //加到数据库
    tmpDoc.add_DcC(DataAccess.common.IntNull(tbxOrderNum.Text),strFileName,FileData,tbxMemo.Text,int.Parse(ViewState["docId"].ToString()));

    getDBImage(FileData,strFileName);

    }public string getDBImage(byte[] buffer,string fileName)
                    {
    string strPath=System.Web.HttpContext.Current.Server.MapPath("\\DataPlat\\tempFile\\" + fileName );
    //WriteToFile(strPath,ref tempFileImage.fileImage ); // Create a file
    FileStream newFile = new FileStream(strPath, FileMode.Create); // Write data to the file
    newFile.Write(buffer , 0, buffer.Length ); // Close file
    newFile.Close(); return strPath;
    }
      

  5.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=D8F961C3-CBC1-4591-143D-236B572EB89F
      

  6.   

    这只是webForm 中的!
    对于WinForm我想一定要有client 和Server
    有个建议!
    在WinForm中开个子窗口!可以访问Web页面 的!现在有一些叫网络硬盘的!
    他们的原理其实也是C/S的!要装客户端控件,通过客户端控件访问服务器!
    而且不是用的80端口!http通常用80端口!
      

  7.   

    我们一直用 WebService传输二进制流。
      

  8.   

    简单的方法:在winform上嵌入一个小ie窗口,放一个type=file 的input ,将form的action
    设到你要上传的服务器端接收文件的url。
    条件是外网服务器上已有上传文件的Web页面。
      

  9.   

    引用saucer提供的内容:
    string lcUrl = "http://www.west-wind.com/testpage.wwd";HttpWebRequest loHttp =    (HttpWebRequest) WebRequest.Create(lcUrl); // *** Send any POST datastring lcPostData =    "Name=" + HttpUtility.UrlEncode("Rick Strahl") +    "&Company=" + HttpUtility.UrlEncode("West Wind "); loHttp.Method="POST";byte [] lbPostBuffer = System.Text.                                  Encoding.GetEncoding(1252).GetBytes(lcPostData);loHttp.ContentLength = lbPostBuffer.Length; Stream loPostData = loHttp.GetRequestStream();loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);loPostData.Close(); HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse(); Encoding enc = System.Text.Encoding.GetEncoding(1252); StreamReader loResponseStream =    new StreamReader(loWebResponse.GetResponseStream(),enc); string lcHtml = loResponseStream.ReadToEnd(); loWebResponse.Close();loResponseStream.Close();-------------------------------------------------
    //  pass Proxy string and bypass local machineWebProxy loProxy = new WebProxy("http://proxy-server.mine.com:8080",true); // ** ByPassListstring[] cByPass = new string[2];cByPass[1] = "http://someserver.net";cByPass[2] = http://192.0.0.1 loProxy.BypassList = cByPass; // ** Proxy AuthenticationloProxy.Credentials = new NetworkCredential("proxyusername","pass"); Request.Proxy = loProxy;
      

  10.   

    上面有些同志建议我在winform中做一个访问web的功能就行了,这个我向老板提过,他说不行。
      

  11.   

    就是在winform中来上传文件到某网站的根目录(不用考虑什么用户认证什么的)就行了,
    怎么解决呢???
    我睡觉前再顶一下吧!!!!!
      

  12.   

    你在服务器端的设置是什么?是IIS么?如果是的话,1。如果不需要通过代理,那么使用System.Net.WebClient类,下面这个例子包括了客户端编码以及服务器端ASPX页面的编码http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebclientclassuploadfiletopic.asp2. 如果需要通过代理,那么使用System.Net.HttpWebRequest类服务器端ASPX页面的编码可以参考下面这个例子Uploading Files with ASP.NET
    http://www.aspheute.com/english/20000802.asp客户端编码可以参考
    Retrieving HTTP content in .NET
    http://www.west-wind.com/presentations/dotnetWebRequest/dotnetWebRequest.htm里面的那个HTTP file upload method for multi-part forms例子详述了怎么基于multipart/form-data的enctype 数据格式, 来上传文件数据格式参考
    http://www.aspzone.com/articles/160.aspx#ParsingRequest
      

  13.   

    为什么我用"myWebClient.UploadFile(uriString,"POST",fileName);(其中uriString = "http://localhost/Web_upFile/file/":就是把文件上传到服务器的路径)"。就报出“"远程服务器返回错误: (405) 不允许的方法。"”
    这是怎么回事啊
      

  14.   

    解决了,搞了半天是我的iis目录没设置写入。