2 Replies Latest reply on Jan 2, 2009 7:54 PM by flexstone

    How to call a php file from AIR?

    Mauro Martins.
      Hello guys! I am having a problem trying to do an image upload from an AIR application.

      I am uing FileReference and this is what i am doing:

      private function doFile (e:Event) : void {
      var fileReference:FileReference = new FileReference();
      fileReference.addEventListener(Event.SELECT,fileSelectHandler);
      fileReference.addEventListener(IOErrorEvent.IO_ERROR,fileErrorHandler);
      fileReference.addEventListener(ProgressEvent.PROGRESS,progressHandler);

      var fileFilter:FileFilter = new FileFilter ("Images", "*.jpg");
      fileReference.browse([fileFilter]);
      }

      private function fileSelectHandler(event:Event):void {
      trace("You selected a file name " + event.target.name + " that is " + event.target.size + " bytes in size");
      var uploadURL:URLRequest = new URLRequest(" http://www.myurl.com/uploadImage.php");
      var thisFileRef:FileReference = FileReference(event.target);
      thisFileRef.upload(uploadURL);
      }

      In Flash trace i am getting this problem:

      A file IO error has occurred: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2038: File I/O Error. URL: http://www.myurl.com/uploadImage.php" errorID=2038]

      And if i use Service Capture to show the caller get this error:

      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
      <HTML><HEAD>
      <TITLE>403 Forbidden</TITLE>
      </HEAD><BODY>
      <H1>Forbidden</H1>
      You don't have permission to access /uploadImage.php
      on this server.<P>
      <P>Additionally, a 404 Not Found
      error was encountered while trying to use an ErrorDocument to handle the request.
      <HR>
      <ADDRESS>Apache/1.3.41 Server at www.myurl.com Port 80</ADDRESS>
      </BODY></HTML>

      I think i need to use crossdomain.xml right? I that so, how can i use to make it work for everyone who use my application all around the world without having problems?

      Thank you very much!!