想在c#中模仿php代码.
我想捕获从以下Flash Actionscript发布的原始图像数据:
function onSaveJPG(e:Event):void{ var myEncoder:JPGEncoder = new JPGEncoder(100); var byteArray:ByteArray = myEncoder.encode(bitmapData); var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream"); var saveJPG:URLRequest = new URLRequest("save.aspx"); saveJPG.requestHeaders.push(header); saveJPG.method = URLRequestMethod.POST; saveJPG.data = byteArray; var urlLoader:URLLoader = new URLLoader(); urlLoader.addEventListener(Event.COMPLETE, sendComplete); urlLoader.load(saveJPG); function sendComplete(event:Event):void{ warn.visible = true; addChild(warn); warn.addEventListener(MouseEvent.MOUSE_DOWN, warnDown); warn.buttonMode = true; } }
在Save.aspx.cs页面的页面加载上.这是我试图模仿的PHP代码 -
if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){ $jpg = $GLOBALS["HTTP_RAW_POST_DATA"]; $img = $_GET["img"]; $filename = "images/poza_". mktime(). ".jpg"; file_put_contents($filename, $jpg); } else{ echo "Encoded JPEG information not received."; }
任何指针和建议将不胜感激.谢谢 !
这样的事情对你有用吗?
byte[] data = Request.BinaryRead(Request.TotalBytes);