ASP中的PHP $ HTTP_RAW_POST_DATA

时间:2013-04-14 21:49:39

标签: php html actionscript-3 vbscript

我正在使用Flash应用程序更新经典的asp页面,我需要在vbscript下重现PHP的$ HTTP_RAW_POST_DATA函数(OR C#.NET,因为它也在IIS7上)。这是我到目前为止所做的,但不起作用。浏览器告诉我,由于错误或损坏,它无法显示图像。提前完成。

AS3代码

vid_out = new Video();
vid_out.x = 0;
vid_out.y = 0;
vid_out.width = cam.width;
vid_out.height = cam.height;
vid_out.attachCamera(cam);
addChild(vid_out);

var bitmapData:BitmapData = new BitmapData(640, 480);
bitmapData.draw(vid_out);
var encoder:JPGEncoder = new JPGEncoder();
var byteArray:ByteArray = encoder.encode(bitmapData);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("/capture.asp?i=blah.jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = byteArray;
navigateToURL(jpgURLRequest, "_blank");

非工作的vbscript代码

Function RSBinaryToString(xBinary)
  Dim Binary
  If vartype(xBinary)=8 Then Binary = MultiByteToBinary(xBinary) Else Binary = xBinary

  Dim RS, LBinary
  Const adLongVarChar = 201
  Set RS = CreateObject("ADODB.Recordset")
  LBinary = LenB(Binary)

  If LBinary>0 Then
    RS.Fields.Append "mBinary", adLongVarChar, LBinary
    RS.Open
    RS.AddNew
    RS("mBinary").AppendChunk Binary
    RS.Update
    RSBinaryToString = RS("mBinary")
  Else
    RSBinaryToString = ""
  End If
End Function

photoname = trim(request.querystring("i"))

Dim ByteCount, BinRead
ByteCount = Request.TotalBytes

If ByteCount > 0 Then
BinRead = Request.BinaryRead(ByteCount)
Response.ContentType = "image/jpeg"
Response.AddHeader "Content-Disposition", "inline; filename=" & photoname
Response.BinaryWrite(RSBinaryToString(BinRead))
Response.End()
End If

'正在运行的vbscript代码

我只是使用服务器上的实际文件夹路径。您也可以使用servermappath。

photoname = trim(request.querystring("i"))
folder = "C:\some_folder\"

tofolder = folder & photoname

Dim BinaryData, ByteCount 
ByteCount = Request.TotalBytes 
BinaryData = Request.BinaryRead(ByteCount)

Set objADO = Server.CreateObject("ADODB.Stream")
objADO.Type = 1
objADO.Open
objADO.Write BinaryData
objADO.SaveToFile tofolder, 2
Set objADO = Nothing

1 个答案:

答案 0 :(得分:1)

请参阅Request Object reference

具体来说,您会对Request.TotalBytes属性感兴趣,以获取请求正文大小和Request.BinaryRead方法来读取请求正文。

来自MSDN的

引用:的VBScript

<% 
Dim vntPostedData, lngCount 
lngCount = Request.TotalBytes 
vntPostedData = Request.BinaryRead(lngCount) 
%>