
582
ActionScript classes
You can send data to the server with the
upload()
call by appending parameters to the URL;
for example,
http://www.myserver.com/upload.cgi?userID=jdoe
On some browsers, URL strings are limited in length. Lengths greater than 256 characters
may fail on some browsers or servers.
Returns
Boolean
- A value of
false
in any of the following situations:
■
FileReference.browse()
has not yet been successfully called on this object, or if
FileReferenceList.browse()
has not yet been successfully called with this object in its
filelist
array.
■
The protocol is not HTTP or HTTPS.
■
A security violation occurs; that is, if your SWF file attempts to access a file from a server
that is outside your SWF files's security sandbox.
■
The
url
parameter is of the incorrect type or format.
■
The call does not have the correct number of parameters.
Example
The following example shows an implementation of the
upload()
method by first prompting
the user to select a file to upload, then handling the
onSelect
and
onCancel
listeners, and
finally handling the results of the actual file upload.
import flash.net.FileReference;
var allTypes:Array = new Array();
var imageTypes:Object = new Object();
imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)";
imageTypes.extension = "*.jpg; *.jpeg; *.gif; *.png";
allTypes.push(imageTypes);
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
if(!file.upload("http://www.yourdomain.com/
yourUploadHandlerScript.cfm")) {
trace("Upload dialog failed to open.");
}
}
listener.onCancel = function(file:FileReference):Void {
trace("onCancel");
}
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...