2009-11-03 81 views
0

这里是我的AS3代码:从FLASH中获取POST数据到ASP.Net

var jpgEncoder:JPGEncoder = new JPGEncoder(100); 
var jpgStream:ByteArray = jpgEncoder.encode(bitmapData); 
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream"); 
var jpgURLRequest:URLRequest = new URLRequest("/patients/webcam.aspx"); 
jpgURLRequest.requestHeaders.push(header); 
jpgURLRequest.method = URLRequestMethod.POST; 
jpgURLRequest.data = jpgStream; 
navigateToURL(jpgURLRequest, "_self"); 

这是我的ASP.Net代码

try 
      { 
       string pt = Path.Combine(PathFolder, "test.jpg"); 
       HttpFileCollection fileCol = Request.Files; 
       Response.Write(fileCol.Count.ToString()); 
       foreach (HttpPostedFile hpf in fileCol) 
       { 
        hpf.SaveAs(pt); 
       } 
      } 
      catch (Exception ex) 
      { 
       Response.Write(ex.Message); 
      } 

我发现了一个奇怪的错误,是HttpFox提到:“ NS_ERROR_NET_RESET“

+0

可能重复的[如何从Flash到ASP.Net页面捕获http post文件?](http://stackoverflow.com/questions/1634974/how-to-catch-an-http-post-file- from-flash-to-asp-net-page) – 2014-03-30 13:15:58

回答

0

如果您想要 使用c#Request.Files属性,则应该将contentType替换为multipart/form-data。

参见http://msdn.microsoft.com/en-us/library/system.web.httprequest.files.aspx

而且它要求在闪光代码一些变化,作为数据应以MIME多格式进行编码。

+0

hello! 它是一个“multipart/form-data”内容类型吗? 即时通讯仍然无法接收数据,虽然HttpFox给我的内容长度,我的C#代码没有得到正确的价值。它只是说0. – 2009-11-04 00:33:42

+0

我得到的错误:“线程被中止。” – 2009-11-04 00:35:54

+0

我认为你需要以某种方式编码数据,你不能直接发送二进制数据 – rossoft 2009-11-04 06:17:47