Solved

Downloading binary

Posted on 2009-04-11
2
310 Views
Last Modified: 2013-11-11
Hello.

Just made a webcam application in flash cs3/actionscript 3. I want to be able to save bitmap data from the swf file as a jpg. I have pasted some working php code below. I would ideally like to have it in asp though as my server is based on that. Does anybody have any ideas  about doing this is asp. I have done quite a bit asp over the last few years but must admit this is beyond me.

Thanks in advance for any help.
if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
	// get bytearray
	$jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
 
	// add headers for download dialog-box
	header('Content-Type: image/jpeg');
	header("Content-Disposition: attachment; filename=".$_GET['name']);
	echo $jpg;
}

Open in new window

0
Comment
Question by:ranski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Matthew Kelly earned 500 total points
ID: 24124198
See if this helps you: http://forums.aspfree.com/asp-development-5/equivalent-to-php-s-http-raw-post-data-in-asp-40108.html

So something like below...

I have used that to save binary data stored as an image field in an SQL database to an actual .jpg file using the ADODB.Recordset object so you should be able to do it with the post data as well.
<%
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
 
 
 
 
Dim ByteCount, BinRead
ByteCount = Request.TotalBytes
If ByteCount > 0 Then
  BinRead = Request.BinaryRead(ByteCount)
  Response.ContentType = GetContentType("image/jpeg")
  Response.AddHeader "Content-Disposition", "attachment;filename=" + Request("name")
  Response.BinaryWrite(RSBinaryToString(BinRead))
  Response.End()
End If
%>
<html>
	<head><title>Raw Post Data</title></head>
	<body>
		<form action="binaryread.asp" method="post">
			<input type="text" name="txtTesting" />
			<input type="submit" name="btnSubmit" value="Submit" />
		</form>
	</body>
</html>

Open in new window

0
 

Author Comment

by:ranski
ID: 24124318
Great advice. Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question