2009-11-03 85 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