MultiPowUpload object methods
browseFiles([fileTypes:Array])
Displays a file-browsing dialog box in which the user can select a local file to upload. The dialog box is native to the user's operating system. Only one browseFiles()
session can be performed at a time (because only one dialog box can be displayed at a time).
You can pass an array of file types to determine which files the dialog box displays.
fileTypes:Array
[optional] - An array of file types used to filter the files displayed in the dialog box. If you omit this parameter, all files are displayed. You can use one of two formats for the array:
The two formats are not interchangeable in a single browseFiles()
call. You must use one or the other.
The list of extensions is used to filter the files in Windows, depending on the file selected by the user. It is not actually displayed in the dialog box. To display the file types for users, you must list the file types in the description string as well as in the extension list. The description string is displayed in the dialog box in Windows. (It is not used on the Macintosh.) On the Macintosh, if you supply a list of Macintosh file types, that list is used to filter the files. If you don't supply a list of Macintosh file types, the list of Windows extensions is used.
uploadAll([URL:String])
Starts the upload of a files in list to a remote server.
Listeners receive events to indicate the progress, success, or failure of the upload. Files are uploaded one by one.
The file is uploaded to the URL passed in the URL
parameter. The URL must be a server script configured to accept uploads. Flash Player uploads files using the HTTP POST
method. The server script that handles the upload should expect a POST
request with the following elements:
Content-Type
element of multipart/form-data
Content-Disposition
element with a name
attribute set to "Filedata"
and a filename
attribute set to the name of the original fileHere is a sample POST
request:
You can send data to the server with the uploadAll()
call by appending parameters to the URL.
Note: If your server requires user authentication, only SWF files running in a browser--that is, using the browser plug-in or ActiveX control--can provide a dialog box to prompt the user for a user name and password for authentication, and only for downloads. For uploads that use the plug-in or ActiveX control, and for uploads and downloads that use the stand-alone or external player, the file transfer fails.
When using this method, consider the Flash Player security model:
URL:String
[optional] - The URL of the server script configured to handle upload through HTTP POST
calls. If you omit this parameter, URL specified by uploadUrl
Flash object parameter will be used. The URL can be HTTP only, not HTTPS.
You can send data to the server with the uploadAll()
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.
uploadFiles(indeces:Array, [URL:String])
The same as uploadAll()
method, but uploads only files which indeces specified in indeces
parameter.
indeces:Array
- An array of indices of the items to upload.
The following example demonstates upload first 3 files selected by user:
downloadAll()
Displays a dialog box in which the user can download files in fileList
from a remote server.
This method for each file first opens an operating-system dialog box that asks the user to enter a filename and select a location on the local computer to save the file. When the user selects a location and confirms the download operation (for example, by clicking Save), the download from the remote server begins. Listeners receive events to indicate the progress, success, or failure of the download. To ascertain the status of the dialog box and the download operation after calling download()
, your Java Script code must listen for events by using event listeners such as MultiPowUpload_onProgress
, MultiPowUpload_onError
and MultiPowUpload_onComplete
.
Only one downloadAll()
session can be performed at a time (because only one dialog box can be displayed at a time).
This method supports downloading of any file type, with either HTTP or HTTPS. You can also send data to the server with the downloadAll()
call by appending parameters to the URL of the files, for the server script to parse.
Attention! Flash download feature loads downloaded file to memory and don't free it even after saving file to hard disk. Therefore use Flash download only for small files. For large files we recommend to use native browser download feature (Direct link to file).
Note: If your server requires user authentication, only SWF files that are running in a browser--that is, using the browser plug-in or ActiveX control--can provide a dialog box to prompt the user for a user name and password for authentication, and only for downloads. For uploads using the plug-in or ActiveX control, and for uploads and downloads using the stand-alone or external player, the file transfer fails.
When using this method, consider the Flash Player security model:
The following example attempts to download a file using the downloadAll()
method
downloadFiles(indeces:Array)
The same as downloadAll()
method, but downloads only files in fileList
which indeces specified in indeces
parameter.
indeces:Array
- An array of indices of the items to download.
The following example demonstates download only files selected by user:
removeItemAt(index:Integer)
Method; removes the item from fileList
at the specified index position. The list indices after the specified index collapse by one.
Calling this method modifies the data in fileList
object.
index
A number that indicates the position of the item. The value must be greater than 0 and less than fileList.length
.
The following code clears the selected items in a list when a button is clicked:
removeAll()
Method; removes all items in the list.
cancelUploadDownload()
Cancels any ongoing upload or download operation.
The following example uploads approximately half of the files and then cancels the upload.
sendAndLoadVars(keys:Array, values:Array, URL:String, [method:String])
Posts variables to the specified URL. The server response is downloaded, parsed as variable data, and the resulting variables are placed in the response
parameter or MultiPowUpload_onLoadVars
event.
When using this method, consider the Flash Player security model:
For Flash Player 8:
Method sends variables as classic FORM fields values.
keys:Array
- An array of variables names.
values:Array
- An array of variables values. Length of keys
and values
arrays should be the same.
URL:String
- A string; the URL to which to upload variables. If the SWF file issuing this call is running in a web browser, url
must be in the same domain as the SWF file.
method:String
[optional] - A string; the GET
or POST
method of the HTTP protocol. The default value is POST
.
The following example uploads 2 variables to server side ASP.NET script and shows server response.
formproc.aspx file code:
download(URL: String, [defaultFileName:String], [size:Integer])
Displays a dialog box in which the user can download a file from a remote server. Method is the same as downloadAll()
or downloadFiles()
methods, but it downloads file specified by URL
parameter, not file from list. Method can be called then Flash is in Uploader or Downloader mode.
URL:String
- The URL of the file to download to the local computer. You can send data to the server with the download()
call by appending parameters to the URL, for the server script to parse. For example: http://www.myserver.com/picture.jpg?userID=jdoe
On some browsers, URL strings are limited in length. Lengths greater than 256 characters may fail on some browsers or servers.
defaultFileName:String
[optional] - The default filename displayed in the dialog box, for the file to be downloaded. This string cannot contain the following characters: / \ : * ? " < > | %
If you omit this parameter, the filename of the remote URL is parsed out and used as the default.
size:String
[optional] - The size of the file, in bytes.
If you omit this parameter, Progress Bar willn't show correct info.
The following example downloads single file.
addFileToDownload(URL: String, [name:String], [size:Integer])
Adds file to the list to be downloaded. Files in list can be downloaded using downloadAll()
or downloadFiles()
methods.
URL:String
- The URL of the file. You can send data to the server with the download()
call by appending parameters to the URL, for the server script to parse. For example: http://www.myserver.com/picture.jpg?userID=jdoe
On some browsers, URL strings are limited in length. Lengths greater than 256 characters may fail on some browsers or servers.
name:String
[optional] - The filename displayed in the list. This string cannot contain the following characters: / \ : * ? " < > | %
The same filename will be displayed as default in the Save As dialog box, for the file while download.
size:Integer
[optional] - The size of the file, in bytes.
If you omit this parameter, Progress Bar willn't show correct info while download.
The following example adds and then downloads single file.
loadImage(URL: String, [width:Integer], [height:Integer])
Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into Flash body. If you load an animated GIF, only the first frame is displayed.
MultiPowUpload_onLoaderProgress
handler is invoked as the loading process progresses.MultiPowUpload_onError
handler is invoked if the image cannot be loaded. MultiPowUpload_onLoaderComplete
handler is invoked when a file completes downloadingWhen using this method, consider the Flash Player security model:
URL:String
- The absolute or relative URL of the SWF, JPEG, GIF, or PNG file to be loaded. A relative path must be relative to the SWF file at level 0. Absolute URLs must include the protocol reference, such as http:// or file:///. Filenames cannot include disk drive specifications.
width:Integer
[optional] - New width of the region, in pixels.
height:Integer
[optional] - New height of the region, in pixels.
The following example loads new image and resizes region.