# Upload/Save ByteArray (Urgent Please)

**URL:** https://forum.kirupa.com/t/upload-save-bytearray-urgent-please/327915
**Category:** flash
**Created:** [April 5, 2012, 11:20am UTC](https://forum.kirupa.com/t/upload-save-bytearray-urgent-please/327915 "2012-04-05T11:20:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![colouredFunk](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@colouredFunk](https://forum.kirupa.com/u/colouredFunk)
#### Post date: [April 5, 2012, 11:20am UTC](https://forum.kirupa.com/t/upload-save-bytearray-urgent-please/327915/1 "2012-04-05T11:20:03Z")

</div>

Hello all,

I’m tying to upload a file to my server, for a project due by EOP today 0\_o… I’m stuck on the ServerSide code though…

I think it’s the ASP code that I’ve got wrong… Has anyone got some examples? I’m sure I’ve seen some on the Net, but I can’t seem to find anything at the moment…

Thanks

Here is my AS3 Code

```auto

var ba:ByteArray = e.currentTarget.data as ByteArray;
var baURLRequest:URLRequest = new URLRequest("http://www.severadd.com/toolkit/app/scripts/saveByteArray.asp");        
baURLRequest.requestHeaders.push(new URLRequestHeader("Content-type", "application/octet-stream"));
baURLRequest.method = URLRequestMethod.POST;
//Add jpg byte array to URL request
var vars:URLVariables = new URLVariables();
vars.byteArray = ba
baURLRequest.data = vars;
//Get the URLLoader ready
var sendBALoader:URLLoader = new URLLoader(baURLRequest);
sendBALoader.dataFormat = URLLoaderDataFormat.BINARY;
sendBALoader.addEventListener(Event.COMPLETE, onHTTPComplete);
sendBALoader.load(baURLRequest)

```

ASP CODE

```auto

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
FileName = "C:\Home\a\r	oolkit\app\uploads\WNS Channel Partner\PartnerEmpower_Framework_Overview_for_Partners_v3_021211.ppt"'Request("filaname")
ByteArray = Request("ba")
 Const adTypeBinary = 1
  Const adSaveCreateOverWrite = 2
  
  'Create Stream object
  Dim BinaryStream
  Set BinaryStream = CreateObject("ADODB.Stream")
  
  'Specify stream type - we want To save binary data.
  BinaryStream.Type = adTypeBinary
  
  'Open the stream And write binary data To the object
  BinaryStream.Open
  BinaryStream.Write ByteArray
  
  'Save binary data To disk
  BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
 %>

```
