views:

458

answers:

2

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

im getting a weird error, HttpFox mentioned: "NS_ERROR_NET_RESET"

Any help would be excellent!

Thanks!

A: 

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.

rossoft
hello!is it a "multipart/form-data" content type?im still having trouble receiving the data, though the HttpFox gives me the content length, my c# code doesn't get the right value. it just says 0.
Martin Ongtangco
i'm getting the error: "Thread was being aborted."
Martin Ongtangco
I think you need to encode somehow the data, you can not directly send the binary data
rossoft
That encoding is not easy, I recommend you to look into third party classes in order to do it like MultipartURLLoader:http://code.google.com/p/in-spirit/source/browse/trunk/projects/MultipartURLLoader/ru/inspirit/net/MultipartURLLoader.as
rossoft