MultiPowUpload 3.1
Methods |
![]() ![]() |
MultiPowUpload object methods
For more information on how to use MultiPowUpload methods see How to section.
getId
getId()
Returns a unique identificator of MultiPowUpload instance.
getVersion
getVersion():String
Returns a string representation of the MultiPowUpload version number.
setParameter
setParameter(paramName:String, paramValue:String)
Sets a parameter at the runtime. It is possible to modify most parameters at the runtime. MultiPowUpload reloads interface immediately.
paramName:String
- The name of parameter
paramValue:String
- Value for a specified parameter.
function MultiPowUpload_onMovieLoad()
{
MultiPowUpload.setParameter("backgroundColor","#0000FF");
}
getParameter
getParameter(String paramName):String
Returns a current value of the parameter.
paramName:String
- The name of parameter
function MultiPowUpload_onMovieLoad()
{
alert(MultiPowUpload.getParameter("backgroundColor"));
}
getProgressInfo
ProgressInfo getProgressInfo()
Returns an instance of ProgressInfo class.
var progress = MultiPowUpload.getProgressInfo();
getFiles
getFiles() ListItem[]
Returns an array of ListItem objects. Each object represents a file selected by a user.
The properties of ListItem objects are described in the ListItem class documentation.
//Show files info var list = MultiPowUpload.getFiles(); for(var i=0; i<list.length; i++) { window.alert("File " + list[i].name + " in list"); }
getFilesCount
getFilesCount():long
Returns a count of files in file list.
getSelectedIndices
getSelectedIndices() int[]
An array of Integer values.
Returns an array of indices of the selected items.
Return value reflects the order in which the items were selected. If you click the second item, then the third item, and then the first item again, getSelectedIndices
returns [1,2,0]
. The value is null
if nothing is selected.
The following example retrieves the selected indices and names of a files selected:
function MultiPowUpload_onListChange()
{
var selIndices = MultiPowUpload.getSelectedIndices();
if(selIndices!=null)
{
for(var i=0; i<selIndices.length; i++)
{
window.alert("File " + MultiPowUpload.getFileAt([selIndices[i]).name + " is selected in list");
}
}
}
getSelectedItems
getSelectedItems() ListItem[]
An array of ListItem objects.
The function returns an array of the selected item objects. In a multiple-selection list, getSelectedItems
lets you access the set of items selected as item objects. The value is null
if nothing is selected.
The following example counts total size of the selected files:
function MultiPowUpload_onListChange()
{
var selItems = MultiPowUpload.selectedItems();
if(selItems!=null)
{
var totalSize = 0;
for(var i=0; i<selItems.length; i++)
{
totalSize += selItems[i].size;
}
window.alert("Total size of a files selected is " + totalSize + " bytes.");
}
}
getFile
getFile(String fileId)
Returns an instance of ListItem object by a specified id.
fileId:String
- Identificator of the file.
getFileAt
getFileAt(index:Integer)
Returns an instance of ListItem object by a specified index of the file.
index:Integer
- An index of the file in the file list.
removeFile
removeFile(String fileId)
The method removes the item with a specified identificator from fileList
.
fileId:String
- Identificator of the file.
The following code clears the selected items in a list when a button is clicked:
function deleteSelected()
{
while(MultiPowUpload.getSelectedItems()!=null)
{
MultiPowUpload.removeFile(MultiPowUpload.getSelectedItems[0].id);
}
}
removeFileAt
removeFileAt(Integer index)
The method removes the item from fileList
in the specified index position. The list has indices after a specified index collapses one 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:
function deleteSelected()
{
while(MultiPowUpload.getSelectedIndices()!=null)
{
MultiPowUpload.removeFileAt(MultiPowUpload.getSelectedIndices[0]);
}
}
removeAll
removeAll()
The method removes all items from the list.
sortFileList
sortFileList(String field, String option)
The method sorts file list .
field:String
- The field to sort: NAME, SIZE or DATE
option:String
- The order to sort: ASC or DESC.
function MultiPowUpload_onAddFiles(files)
{
MultiPowUpload.sortFileList("SIZE", "ASC");
}
uploadAll
uploadAll([String URL])
The method starts the upload of files in list to a remote server. The files are uploaded one by one. If there are images in the list and the value of sendThumbnails parameter is set to true, MultiPowUPload will generate thumbnails for all the images and then starts the upload process.
The file is uploaded to the URL spesified in the URL
parameter. The URL must be a server script configured to accept uploads.
URL:String
[optional] - The URL of the server script configured to handle upload through HTTP POST
calls. If you omit this parameter, URL specified in uploadUrl
parameter will be used.
//Upload of files to a remote server side script after a user selects MultiPowUpload_onAddFiles() file
function
{
MultiPowUpload.uploadAll("uploadfiles.aspx");
}
uploadFiles
uploadFiles(int[] indeces, [String URL])
The method is similar to uploadAll()
, but it uploads only the files which have indeces specified in indeces
parameter.
indeces:int[]
- An array of indices of the items to upload.
URL:String
[optional] - The URL of the server script configured to handle an upload through HTTP POST
calls. If you omit this parameter, URL specified in uploadUrl
parameter will be used.
The following example demonstates the upload of first 3 files selected by a user:
function MultiPowUpload_onAddFiles()
{
var indeces = [0,1,2];
MultiPowUpload.uploadFiles(indeces, "uploadfiles.aspx");
}
cancelUpload
cancelUpload()
The method cancels the upload operation.
The following example uploads approximately half of the files and then cancels the upload.
var isCancelled = false;
function MultiPowUpload_onProgress(file)
{
var progress = MultiPowUpload.getProgressInfo();
if(isCancelled==false && progress.totalPercent >= 50)
{
isCancelled = true;
MultiPowUpload.cancelUpload();
}
}
sendAndLoadVars (MultiPowUpload.sendAndLoadVars method)
sendAndLoadVars(String[] keys, String[] values, String URL, [String method])
The method posts variables to a 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.
keys:String[]
- An array of variables names.
values:String[]
- An array of variables values. Length of keys
and values
arrays should be the same.
URL:String
- URL to the script which should receive variables.
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 a server response.
function MultiPowUpload_onMovieLoad()
{
var keys=["myname", "myID"];
var values=["JDoe", "12345"];
MultiPowUpload.sendAndLoadVars(keys, values, "formproc.aspx", "POST");
}
function MultiPowUpload_onLoadVars(response)
{
window.alert(response);
}
formproc.aspx file code:
<%@ Page language="c#"%>
<%
Response.Write("I got your name "+ Request.Form["myname"] + " and your ID " + Request.Form["myID"]);
%>
addPostField
addPostField(String paramName, String paramVal)
The method adds a parameter to post a request. This parameter will be posted with each uploaded file.
paramName:String
- name of parameter.
paramValue:String
- value of parameter.
function MultiPowUpload_onAddFiles(addedFiles)
{
MultiPowUpload.addPostField("testParameter2", "Test Value 2");
}
removePostField
removePostField(String paramName)
The method removes a parameter with a specified name from a post request.
paramName:String
- name of parameter.
MultiPowUpload.removePostField("testParameter2");
addFilePostField
addFilePostField(String fileId, String paramName, String paramVal)
The method adds a parameter for a file specified by the fileId parameter. This parameter will be posted to the server with a specified file.
fileId:String
- Identificator of file.
paramName:String
- name of parameter.
paramValue:String
- value of parameter.
function MultiPowUpload_onAddFiles(addedFiles)
{
//add post field to first added file
if(addedFiles.length > 0)
MultiPowUpload.addFilePostField(addedFiles[0].id, "testParameter", "Test Value");
}
removeFilePostField
removeFilePostField(String fileId, String paramName)
The method removes a parameter with a "paramName" name from a file specified by the fileId parameter.
fileId:String
- Identificator of file.
paramName:String
- name of parameter.
var fileId = MultiPowUpload.getFiles()[0].id;
MultiPowUpload.removeFilePostField(fileId, "testParameter");
setFileDescription
setFileDescription(String fileId, String description)
The method sets a file description text.
fileId:String
- Identificator of the file.
description:String
- New file of the description text.
var fileId = MultiPowUpload.getFiles()[0].id;
MultiPowUpload.setFileDescription(fileId, "modified description");