views:

85

answers:

1

I am trying to POST a file to a server that replies with some basic status information in the body. Everything is easy from javascript but I was wondering if I could read the status information from the reply using flash. That way I can use the multifile picker flash provides and send several files at once.

BTW would it work with PUT?

+1  A: 

To get information out of your application (one-way information flow)

Using the getURL function, you can use the form which specifies methods.

getURL (url, window, method)

Arguments:

  • url should be the url of the script you want to get data to.
  • window should be a custom named window, or one of the four presets, "_blank", "_parent", "_self" or "_top"
  • method should be "GET" or "POST"

When using the POST method, the current movie clips timeline variables are sent to the script as a seperate block of data after the HTTP POST-request header (exactly the same way a regular HTML form that uses the POST method).

You will need Flash 6 or later on the player to get this to work.

Example:

getURL("http://example.org/myscript.pl", "_top", "POST");

To get information out of scripts (two-way information flow)

If you want to get information back into your flash application from your script, you can use loadVariables with similar arguments, the only difference is the second argument, which is the target for the variables to load into.

i.e. To load variables into the main movie timeline.

loadVariables ("http://example.org/myscript.pl", "_root", "POST");
Jonathan