Hi Slash

 

I am doing something similar using Flex 2.0

 

I am converting a file to binary

 

ByteLoader = new URLLoader();

ByteLoader.dataFormat = URLLoaderDataFormat.BINARY;

ByteLoader.addEventListener (Event.COMPLETE, fileLoadComplete);

                                                

FileRequest = new URLRequest (filePath);

ByteLoader.load (FileRequest);                 

 

then converting it to Base64 using a Base64 class
(http://www.mediakitchen.co.uk/Base64.zip) and uploading this Base64 data by
enclosing it in an xml file

 

var dataStrEncoded:String=Base64.Encode(ByteLoader.data);     

 

var XMLString:String;                                      

                                                

XMLString = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>';

XMLString = '<file>';

XMLString += '<![CDATA[' + dataStrEncoded + ']]>';


XMLString += '</file>';

                                                

var dataToSend:XML = new XML(XMLString);

 

_loader = new URLLoader();       

_loader.addEventListener(Event.COMPLETE,fileUploadCompleteListener);


                                                

_loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorListener);


 


var request:URLRequest = new URLRequest(scriptPath);

request.method = URLRequestMethod.POST;

                                                

var variables:URLVariables = new URLVariables();


variables.xml = XMLString;                           

                                                

request.data = variables;


                                                

_loader.load(request);

 

 

Only problem is the client is reporting that when they are decoding the
encoded data at their end, the data is not what it should be. I am not sure
if it is a problem with how I am reading in the data as binary or the Base64
encoding.

 

I am sure I read there was a built in Base64 encoder class but I can't find
it.

 

Anyone have any info on this? Or indeed any idea why the data I am uploading
to the client is not correct?

 

 

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of slash_n_rose
Sent: 24 September 2007 05:36
To: [email protected]
Subject: [SPAM] [flexcoders] upload file to base64

 

Hi all
Can I convert an uploading file to base64 from flex2.0.. Im using
filereference for uploading a file. Thanks in advance
Slash

 

Reply via email to