Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:58:31+00:00 2026-06-01T01:58:31+00:00

I upload a file using adobe air HTTPService.Send method by passing byte array of

  • 0

I upload a file using adobe air HTTPService.Send method by passing byte array of file content read using FileReference. When I write the set of bytes from the server side (php) it writes the details of the byte array (buff) to the file instead of contents of the file like
“endian=bigEndian&position=0&bytesAvailable=61127&length=61127&objectEncoding=3” . Below I have included the code that how I read the file and send it to server. Is there anyway that i can directly pass the data in the byte array to send method?

File Read

var buff:ByteArray = new ByteArray();
var localFilePath:String = "/Videos/sample.txt";
var uploadedFile:File = new File(localFilePath);
var uploadedFileStream:FileStream = new FileStream();
uploadedFileStream.open(uploadedFile,FileMode.READ);
uploadedFileStream.readBytes(buff);
uploadedFileStream.close();

File upload

var serverPath:String = "http://myurl.com/rests";
var service:mx.rpc.http.mxml.HTTPService=new mx.rpc.http.mxml.HTTPService();
service.url=serverPath;
service.requestTimeout=30;
service.method="POST";
service.contentType="application/x-www-form-urlencoded";
service.addEventListener(ResultEvent.RESULT,onResponceReceive);
service.addEventListener(FaultEvent.FAULT,onResponceFail);

  var userName:String="myusername";
var password:String="mypwd";

var encoder:Base64Encoder = new Base64Encoder();
encoder.insertNewLines=false;
encoder.encode(userName+":"+password);
service.headers={Authorization:"Basic "+encoder.toString()};

try{
    service.send(buff);
}catch(error:Error){
    Alert.show(error.message);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:58:32+00:00Added an answer on June 1, 2026 at 1:58 am

    Try something like this. You will need to set up some variables.

    private function uploadLogo():void {
    
    logof = File.documentsDirectory.resolvePath ("logo.jpg");
    
    ba = new ByteArray();
    stream = new FileStream();
    
    stream.open(logof, FileMode.READ);
    stream.readBytes(ba);
    stream.close();
    
    urlLoaderSend = new URLLoader();
    urlLoaderSend.dataFormat = URLLoaderDataFormat.TEXT;
    urlLoaderSend.addEventListener(Event.COMPLETE, uploadImage, false, 0, true);
    
    var urlRqSend:URLRequest = new URLRequest("http://www.domain.com/uploadImage.php");
    urlRqSend.contentType = "application/octet-stream";
    urlRqSend.method = URLRequestMethod.POST;
    urlRqSend.data = ba;
    urlLoaderSend.load(urlRqSend);
    
    }
    
    
    private function uploadImage(ev:Event):void {
    
    trace("serverresponse "+ev.target.data);
    
    try {
        ba = null;
        stream = null;
        urlRqSend = null;       
        urlLoaderSend.removeEventListener(Event.COMPLETE, uploadImage);
        urlLoaderSend = null;
    } catch (e:Error) {
    
    }
    

    And the PHP

    <?php
    
    
    if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
    {
    
    
    $imagename = "image.jpg";
    
    
    $fp = fopen( "images/$imagename", 'wb' );
    fwrite( $fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ] );
    fclose( $fp );
    echo "OK";}
    else { echo "NoImageSent";}?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to upload file(s) using PrototypeJs request method but I failed. The
When using IE browser and trying to upload file using File.SaveAs method I get
I am trying to upload file using php. I am using the function move_uploaded_file.
If there is a way to Upload file using rest via stream would there
To upload a file using inputType: 'file' , and for a form prescribed fileUpload:
I'm trying to upload a file using Watin and C#. Under Windows XP, Watin
I am trying to upload a file using commons-fileupload-1.1.1.jar file (I know it is
Hi i want to upload mulitiple file using rails 3 and paperclip please help
How to upload a image file using ajax by using prototype.js plugin, I need
I'm using Zend_File_Transfer_Adapter_Http to upload file to my server. There is a bug when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.