Downloading binary

Posted on 2009-04-11
Last Modified: 2013-11-11

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.


	// get bytearray


	// add headers for download dialog-box

	header('Content-Type: image/jpeg');

	header("Content-Disposition: attachment; filename=".$_GET['name']);

	echo $jpg;


Open in new window

Question by:ranski
LVL 18

Accepted Solution

Matthew Kelly earned 500 total points
ID: 24124198
See if this helps you:

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("mBinary").AppendChunk Binary


    RSBinaryToString = RS("mBinary")


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



End If



	<head><title>Raw Post Data</title></head>


		<form action="binaryread.asp" method="post">

			<input type="text" name="txtTesting" />

			<input type="submit" name="btnSubmit" value="Submit" />




Open in new window


Author Comment

ID: 24124318
Great advice. Thanks

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now