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 624717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:13:51+00:00 2026-05-13T19:13:51+00:00

How do I use crossdomain with ftp? I am trying to do a hello

  • 0

How do I use crossdomain with ftp?

I am trying to do a “hello world” level test of FTP in Flex, but for three days now, I cannot overcome the issue with how to coerce flex into accepting my crossdomain policy – even for testing purposes.
Here is my code: The exact error text follows.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="onInitialize()" layout="vertical">

<mx:Script>
<![CDATA[
  import mx.utils.*;
  import mx.controls.Alert;
  private var fileRef:FileReference;
  private var fileSize:uint;
  private var fileContents:ByteArray;
  //you need to initiate two scokets one for sending
  //commands and second for sending data to FTP Server
  //socket for sending commands to FTP
  private var s:Socket
  //responce from FTP
  private var ftpResponce:String;
  //socket for sending Data to FTP
  private var dataChannelSocket:Socket;
  //responce from FTP when sending Data to FTP
  private var dataResponce:String;
  //will hold the IP address of new socket created by FTP
  private var dataChannelIP:String;
  //will hold the Port number created by FTP
  private var dataChannelPort:int;
  private var user:String="I have the right user"; //FTP usernae
  private var pass:String="the pw is correct"; //FTP Password

  private function receiveReply(e:ProgressEvent):void {
    ftpResponce=s.readUTFBytes(s.bytesAvailable)
    var serverResponse:Number=Number(ftpResponce.substr(0, 3));
    if (ftpResponce.indexOf('227') > -1) {
      //get the ip from the string response
      var temp:Object=ftpResponce.substring(ftpResponce.indexOf("(") + 1
        , ftpResponce.indexOf(")"));
      var dataChannelSocket_temp:Object=temp.split(",");
      dataChannelIP=dataChannelSocket_temp.slice(0, 4).join(".");
      dataChannelPort=parseInt(dataChannelSocket_temp[4]) * 256 +
        int(dataChannelSocket_temp[5]);
      //create new Data Socket based on dataChannelSocket and dataChannelSocket port
      dataChannelSocket=new Socket(dataChannelIP, dataChannelPort);
      dataChannelSocket.addEventListener(ProgressEvent.SOCKET_DATA, receiveData);
    }
    //few FTP Responce Codes
    switch (String(serverResponse)) {
      case "220":
        //FTP Server ready responce
        break;
      case "331":
        //User name okay, need password
        break;
      case "230":
        //User  logged in
        break;
      case "250":
        //CWD command successful
        break;
      case "227":
        //Entering Passive Mode (h1,h2,h3,h4,p1,p2).
        break;
      default:
    }
    //for more please
    //http://http://www.altools.com/image/support/alftp/ALFTP_35_help/
    //FTP_response_codes_rfc_959_messages.htm          
    traceData(ftpResponce);
  }

  private function receiveData(e:ProgressEvent):void {
    dataResponce=dataChannelSocket.readUTFBytes(
      dataChannelSocket.bytesAvailable);
    traceData("dataChannelSocket_response—>" + dataResponce);
  }

  private function showError(e:IOErrorEvent):void {
    traceData("Error—>" + e.text);
  }

  private function showSecError(e:SecurityErrorEvent):void {
    traceData("SecurityError–>" + e.text);
  }

  private function onInitialize():void {
    Security.loadPolicyFile("http://www.myUrlIsCorrectInMyProgram.com/crossdomain.xml");
  }

  private function createRemoteFile(fileName:String):void {
    if (fileName != null && fileName != "") {
      s.writeUTFBytes("STOR " + fileName + "\n");
      s.flush();
    }
  }

  private function sendData():void {
    fileContents=fileRef.data as ByteArray;
    fileSize=fileRef.size;
    dataChannelSocket.writeBytes(fileContents, 0, fileSize);
    dataChannelSocket.flush();
  }

  //initialize when application load
  private function upLoad():void {
    fileRef=new FileReference();
    //some eventlistener
    fileRef.addEventListener(Event.SELECT, selectEvent);
    fileRef.addEventListener(Event.OPEN, onFileOpen);
    //this function connects to the ftp server
    connect();
    //send the usernae and password
    this.userName(user);
    this.passWord(pass);
    //if you want to change the directory for upload file
    this.changeDirectory("/test/"); //directory name
    //enter into PASSV Mode
    s.writeUTFBytes("PASV\n");
    s.flush();
  }

  private function onFileOpen(event:Event):void {
  }

  private function traceData(event:Object):void {
    var tmp:String="================================\n";
    ta.text+=event.toString() + "\n";
    ta.verticalScrollPosition+=20;
  }

  private function ioErrorEvent(event:IOErrorEvent):void {
    Alert.show("IOError:" + event.text);
  }

  private function selectEvent(event:Event):void {
    btn_upload.enabled=true;
    filename.text=fileRef.name;
    fileRef.load();
  }

  private function uploadFile():void {
    createRemoteFile(fileRef.name);
    sendData();
  }

  private function connect():void {
    s=new Socket("ftp.myUrlIsCorrectInMyProgram.com", 21);
    s.addEventListener(ProgressEvent.SOCKET_DATA, receiveReply);
    s.addEventListener(IOErrorEvent.IO_ERROR, showError);
    s.addEventListener(SecurityErrorEvent.SECURITY_ERROR, showSecError);
    s.addEventListener(Event.CONNECT, onSocketConnect);
    s.addEventListener(Event.CLOSE, onSocketClose);
    s.addEventListener(Event.ACTIVATE, onSocketAtivate);
  }

  private function onSocketConnect(evt:Event):void {
    //traceData("OnSocketConnect–>"+evt.target.toString());
  }

  private function onSocketClose(evt:Event):void {
    //traceData("onSocketClose–>"+evt.target.toString());
  }

  private function onSocketAtivate(evt:Event):void {
    //traceData("onSocketAtivate–>"+evt.target.toString());
  }

  private function userName(str:String):void {
    sendCommand("USER " + str);
  }

  private function passWord(str:String):void {
    sendCommand("PASS " + str);
  }

  private function changeDirectory(str:String):void {
    sendCommand("CWD " + str);
  }

  private function sendCommand(arg:String):void {
    arg+="\n";
    s.writeUTFBytes(arg);
    s.flush();
  }
]]>

[SWF] /FTP-debug/FTP.swf – 739,099 bytes after decompression
Warning: Domain http://www.myUrlIsCorrectInMyProgram.com does not specify a meta-policy. Applying default meta-policy ‘master-only’. This configuration is deprecated. See http://www.adobe.com/go/strict_policy_files to fix this problem.

Warning: Timeout on xmlsocket://ftp.myUrlIsCorrectInMyProgram.com:843 (at 3 seconds) while waiting for socket policy file. This should not cause any problems, but see http://www.adobe.com/go/strict_policy_files for an explanation.

Warning: [strict] Ignoring policy file at xmlsocket://ftp.myUrlIsCorrectInMyProgram.com:21 due to incorrect syntax. See http://www.adobe.com/go/strict_policy_files to fix this problem.

* Security Sandbox Violation *
Connection to http://ftp.myUrlIsCorrectInMyProgram.com:21 halted – not permitted from http://localhost/FTP-debug/FTP.swf
Error: Request for resource at xmlsocket://ftp.myUrlIsCorrectInMyProgram.com:21 by requestor from http://localhost/FTP-debug/FTP.swf is denied due to lack of policy file permissions.

The “Information” at the URL’s listed above is categorically unintelligable to me.

Please, someone help!

  • 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-05-13T19:13:52+00:00Added an answer on May 13, 2026 at 7:13 pm

    See the crossdomain spec:

    http://learn.adobe.com/wiki/download/attachments/64389123/CrossDomain_PolicyFile_Specification.pdf?version=1

    This covers the warning you have and can help you get this working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use a playlist XML file with JW Player which requires crossdomain.xml
Question: I'm trying to use JSON accross domains, but all i find is JSON
I'm trying to use jQuery to test for a css class applied to an
I'm trying to better understand Cross Site Scripting and lets use: http://api.beatport.com/crossdomain.xml as the
I am trying to use the flXHR javascript library for making cross-domain calls. I
use strict; use warnings; use Time::HiRes qw(sleep); use Test::WWW::Selenium; use Test::More no_plan; use Test::Exception;
How can Nginx serve crossdomain.xml file to a flash/flex program. Basically I need to
I am trying to use OBJECT to embed content from a remote server into
I'm trying to use a framework called appcelerator titanium to make a simple iphone
I'm experiencing the popular Security Sandbox violation... I use Google Maps Flex API and

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.