开发者

retrieve POST data from FLASH to ASP.Net

here's my AS3 code:

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");

And here's my ASP.Net Code

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);
     开发者_JS百科       }

I'm getting a weird error, HttpFox mentioned: "NS_ERROR_NET_RESET"


You should replace the contentType to multipart/form-data if you want to use c# Request.Files property.

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

Also it requires some changes in flash code, as the data should be encoded in MIME multipart format.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜