API: uploader YAHOO.widget.Uploader (YUI Library)

# Yahoo! UI Library

### Uploader 2.8.1

Yahoo! UI Library > uploader > YAHOO.widget.Uploader
Search:
Filters Show Private Show Protected Show Deprecated

## Class YAHOO.widget.Uploader - uses YAHOO.widget.FlashAdapter

Uploader class for the YUI Uploader component.

### Constructor

YAHOO.widget.Uploader `( containerId , buttonSkin , forceTransparent )`

Parameters:
  `containerId <HTMLElement>` Container element for the Flash Player instance.
  `buttonSkin <String>` [optional]. If defined, the uploader is rendered as a button. This parameter must provide the URL of a button skin sprite image. Acceptable types are: jpg, gif, png and swf. The sprite is divided evenly into four sections along its height (e.g., if the sprite is 200 px tall, it's divided into four sections 50px each). Each section is used as a skin for a specific state of the button: top section is "up", second section is "over", third section is "down", and fourth section is "disabled". If the parameter is not supplied, the uploader is rendered transparent, and it's the developer's responsibility to create a visible UI below it.
  `forceTransparent <Boolean>` This parameter, if true, forces the Flash UI to be rendered with wmode set to "transparent". This behavior is useful in conjunction with non-rectangular button skins with PNG transparency. The parameter is false by default, and ignored if no buttonSkin is defined.

### Properties

#### Chart.SWFURL - `private static final object`

Location of the Uploader SWF
Default Value: "assets/uploader.swf"

#### Properties inherited from YAHOO.widget.FlashAdapter:

`_attributes, _containerID, _id, _initialized, _swf, _swfURL`

#### Properties inherited from YAHOO.util.AttributeProvider:

`_configs`

#### Properties inherited from YAHOO.util.EventProvider:

`__yui_events, __yui_subscribers`

### Methods

#### cancel

`void cancel ( fileID )`
Cancels the upload of a specified file. If no file id is specified, all ongoing uploads are cancelled.

Parameters:
  `fileID <String>` The ID of the file whose upload should be cancelled.

#### clearFileList

`void clearFileList ( )`
Clears the list of files queued for upload.

#### disable

`void disable ( )`
Disables the mouse events on the Uploader. If the uploader is being rendered as a button, then the button's skin is set to "disabled" (fourth section of the button skin sprite).

#### enable

`void enable ( )`
Enables the mouse events on the Uploader. If the uploader is being rendered as a button, then the button's skin is set to "up" (first section of the button skin sprite).

#### removeFile

`void removeFile ( fileID )`
Removes the specified file from the upload queue.

Parameters:
  `fileID <String>` The id of the file to remove from the upload queue.

#### setAllowLogging

`void setAllowLogging ( allowLogging )`
Turns the logging functionality on. Uses Flash internal trace logging, as well as YUI Logger, if available.

Parameters:
  `allowLogging <Boolean>` If true, logs are output; otherwise, no logs are produced.

#### setAllowMultipleFiles

`void setAllowMultipleFiles ( allowMultipleFiles )`
Sets the flag allowing users to select multiple files for the upload.

Parameters:
  `allowMultipleFiles <Boolean>` If true, multiple files can be selected. False by default.

#### setFileFilters

`void setFileFilters ( newFilterArray )`
Sets the file filters for the "Browse" dialog.

Parameters:
  `newFilterArray <extensions: extensionString, description: descriptionString, [optional]macType: macTypeString>` An array of sets of key-value pairs of the form The extensions string is a semicolon-delimited list of elements of the form "*.xxx", e.g. "*.jpg;*.gif;*.png".

#### setSimUploadLimit

`void setSimUploadLimit ( simUploadLimit )`
Sets the number of simultaneous uploads when using uploadAll() The minimum value is 1, and maximum value is 5. The default value is 2.

Parameters:
  `simUploadLimit <int>` Number of simultaneous uploads, between 1 and 5.

#### upload

`void upload ( fileID , uploadScriptPath , method , vars , fieldName )`
Starts the upload of the file specified by fileID to the location specified by uploadScriptPath.

Parameters:
  `fileID <String>` The id of the file to start uploading.
  `uploadScriptPath <String>` The URL of the upload location.
  `method <String>` Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default.
  `vars <Object>` The object containing variables to be sent in the same request as the file upload.
  `fieldName <String>` The name of the variable in the POST request containing the file data. "Filedata" by default.

#### uploadAll

`void uploadAll ( uploadScriptPath , method , vars , fieldName )`
Starts uploading all files in the queue. If this function is called, the upload queue is automatically managed.

Parameters:
  `uploadScriptPath <String>` The URL of the upload location.
  `method <String>` Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default.
  `vars <Object>` The object containing variables to be sent in the same request as the file upload.
  `fieldName <String>` The name of the variable in the POST request containing the file data. "Filedata" by default.

#### uploadThese

`void uploadThese ( fileIDs , uploadScriptPath , method , vars , fieldName )`
Starts the upload of the files specified by fileIDs, or adds them to a currently running queue. The upload queue is automatically managed.

Parameters:
  `fileIDs <Array>` The ids of the files to start uploading.
  `uploadScriptPath <String>` The URL of the upload location.
  `method <String>` Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default.
  `vars <Object>` The object containing variables to be sent in the same request as the file upload.
  `fieldName <String>` The name of the variable in the POST request containing the file data. "Filedata" by default.

#### Methods inherited from YAHOO.widget.FlashAdapter:

`_embedSWF, _eventHandler, _getAltText, _getSWFURL, _initAttributes, _loadHandler, _setAltText, destroy, toString`

#### Methods inherited from YAHOO.util.AttributeProvider:

`configureAttribute, fireBeforeChangeEvent, fireChangeEvent, get, getAttributeConfig, getAttributeKeys, refresh, register, resetAttributeConfig, resetValue, set, setAttributeConfig, setAttributes`

#### Methods inherited from YAHOO.util.EventProvider:

`createEvent, fireEvent, hasEvent, subscribe, unsubscribe, unsubscribeAll`

### Events

#### click

`click ( event.type )`
Fires when the uploader is clicked.

Parameters:
  `event.type <String>` The event type

#### fileSelect

`fileSelect ( event.type , event.fileList , event.fileList[].size , event.fileList[].cDate , event.fileList[].mDate , event.fileList[].name , event.fileList[].id )`
Fires when the user has finished selecting files in the "Open File" dialog.

Parameters:
  `event.type <String>` The event type
  `event.fileList <Object>` A dictionary of objects with file information
  `event.fileList[].size <Number>` File size in bytes for a specific file in fileList
  `event.fileList[].cDate <Date>` Creation date for a specific file in fileList
  `event.fileList[].mDate <Date>` Modification date for a specific file in fileList
  `event.fileList[].name <String>` File name for a specific file in fileList
  `event.fileList[].id <String>` Unique file id of a specific file in fileList

#### mouseDown

`mouseDown ( event.type )`
Fires when the mouse is pressed over the Uploader. Only fires when the Uploader UI is enabled and the render type is 'transparent'.

Parameters:
  `event.type <String>` The event type

#### mouseUp

`mouseUp ( event.type )`
Fires when the mouse is released over the Uploader. Only fires when the Uploader UI is enabled and the render type is 'transparent'.

Parameters:
  `event.type <String>` The event type

#### rollOut

`rollOut ( event.type )`
Fires when the mouse rolls out of the Uploader.

Parameters:
  `event.type <String>` The event type

#### rollOver

`rollOver ( event.type )`
Fires when the mouse rolls over the Uploader.

Parameters:
  `event.type <String>` The event type

#### uploadCancel

`uploadCancel ( event.type , event.id )`
Fires when an upload for a specific file is cancelled.

Parameters:
  `event.type <String>` The event type
  `event.id <String>` The id of the file with which the upload has been cancelled.

#### uploadComplete

`uploadComplete ( event.type , event.id )`
Fires when an upload for a specific file is complete.

Parameters:
  `event.type <String>` The event type
  `event.id <String>` The id of the file for which the upload has been completed.

#### uploadCompleteData

`uploadCompleteData ( event.type , event.id , event.data )`
Fires when the server sends data in response to a completed upload.

Parameters:
  `event.type <String>` The event type
  `event.id <String>` The id of the file for which the upload has been completed.
  `event.data <String>` The raw data returned by the server in response to the upload.

#### uploadError

`uploadError ( event.type , event.id , event.status )`
Fires when an upload error occurs.

Parameters:
  `event.type <String>` The event type
  `event.id <String>` The id of the file that was being uploaded when the error has occurred.
  `event.status <String>` The status message associated with the error.

#### uploadProgress

`uploadProgress ( event.type , event.id , bytesLoaded , bytesTotal )`
Fires when new information about the upload progress for a specific file is available.

Parameters:
  `event.type <String>` The event type
  `event.id <String>` The id of the file with which the upload progress data is associated
  `bytesLoaded <Number>` The number of bytes of the file uploaded so far
  `bytesTotal <Number>` The total size of the file

#### uploadStart

`uploadStart ( event.type , event.id )`
Fires when an upload of a specific file has started.

Parameters:
  `event.type <String>` The event type
  `event.id <String>` The id of the file that's started to upload

#### Events inherited from YAHOO.widget.FlashAdapter:

`altTextChange, backgroundColorChange, beforeAltTextChange, beforeBackgroundColorChange, beforeExpressInstallChange beforeSwfURLChange beforeVersionChange beforeWmodeChange contentReady expressInstallChange swfURLChange versionChange wmodeChange`

#### Configuration attributes inherited from YAHOO.widget.FlashAdapter:

`altText, backgroundColor, expressInstall swfURL version wmode`

Copyright © 2010 Yahoo! Inc. All rights reserved.