13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with the file system<br />

By default, Flash Player does not attempt to s<strong>en</strong>d a test upload, although you can override this default by passing a value<br />

of true as the third parameter to the upload() method. The purpose of the test upload is to check whether the actual<br />

file upload will be successful and that server auth<strong>en</strong>tication, if required, will succeed.<br />

Note: A test upload occurs only on Windows-based Flash Players at this time.<br />

The server script that handles the file upload should expect an HTTP POST request with the following elem<strong>en</strong>ts:<br />

Cont<strong>en</strong>t-Type with a value of multipart/form-data.<br />

Cont<strong>en</strong>t-Disposition with a name attribute set to “Filedata” and a fil<strong>en</strong>ame attribute set to the name of the<br />

original file. You can specify a custom name attribute by passing a value for the uploadDataFieldName parameter<br />

in the FileRefer<strong>en</strong>ce.upload() method.<br />

The binary cont<strong>en</strong>ts of the file.<br />

Here is a sample HTTP POST request:<br />

POST /handler.asp HTTP/1.1<br />

Accept: text/*<br />

Cont<strong>en</strong>t-Type: multipart/form-data;<br />

boundary=----------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6<br />

User-Ag<strong>en</strong>t: Shockwave Flash<br />

Host: www.mydomain.com<br />

Cont<strong>en</strong>t-L<strong>en</strong>gth: 421<br />

Connection: Keep-Alive<br />

Cache-Control: no-cache<br />

------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6<br />

Cont<strong>en</strong>t-Disposition: form-data; name="Fil<strong>en</strong>ame"<br />

sushi.jpg<br />

------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6<br />

Cont<strong>en</strong>t-Disposition: form-data; name="Filedata"; fil<strong>en</strong>ame="sushi.jpg"<br />

Cont<strong>en</strong>t-Type: application/octet-stream<br />

Test File<br />

------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6<br />

Cont<strong>en</strong>t-Disposition: form-data; name="Upload"<br />

Submit Query<br />

------------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6<br />

(actual file data,,,)<br />

The following sample HTTP POST request s<strong>en</strong>ds three POST variables: api_sig, api_key, and auth_tok<strong>en</strong>, and uses<br />

a custom upload data field name value of "photo":<br />

Last updated 6/6/2012<br />

662

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!