ActiveXPowUpload 1.2.0.5
Methods |
![]() ![]() |
ShowSelectDownloadFolderDialog method
RemoveSelectedDownloadFiles method
Variant GetItem(Index:Variant)
Method returns a FileItem object coresponding to some item in the upload file list. The method allows to get item by numerical index or by file path.
When there is no item corresponding to the index specified (incorrect index), a null value is returned. See examples section.
The prefered way to get a reference to a FileItem object is using a numerical index, that is more effiecient, then refering by file path.
It may be other a number or a string, the other types are not allowed. When it is a number, it is interpreted as a 0-based index of the item in the upload file list. The value must be greater than or equal to 0 and less than ActiveXPowUpload.FileListItemCount
. You should convert index value if it has String type but stores a number!
When the index is a string, it is interpreted as a full path of the item in the upload file list. Comparision is case insensitive.
See also UploadItems.
<script language="jscript"> var file = ActiveXPowUpload.GetItem(0); // Get file by position; file = ActiveXPowUpload.GetItem("c:\\file.jpg"); // Get file by its full path; var index = "0"; file = ActiveXPowUpload.GetItem(parseInt(index)); // Use this to convert a string into a number file = ActiveXPowUpload.GetItem("incorrect index"); // here file == null </script>
void Upload()
Upload files of the upload file list and text items in the Form items list.
There are some restrictions on when the upload method can be invoked. It is an error to start upload twice. You must always wait for the last upload to terminate before starting it again. You are not allowed to start upload inside an event handler. Here “event handler” means only a handler of the ActiveXPowUpload event like OnUploadBegin, OnUploadProgress and so on.
Starting from version 1.1.0 the upload method always waits for upload termination.
ActiveXPowUpload sends files in the order they appear in the file list. Each file contained within a separate part with a name "FILE<N>". Where <N> is the index of the file in the list. Index is 0-based.
ActiveXPowUpload traverses a number of upload states while performing upload. The state determines what you can do with the control, what methods you can invoke, what properties you can change.
ActiveXPowUpload.Upload();
void Stop()
Cancels upload. An upload process is notified to terminate. After a while the upload process notices the cancel request and cancels upload. Sometimes, though, the upload progress might complete before the notification received. In this case the upload terminates as usual. The stop methods doesn't wait for upload termination. Generally you can't start the upload immediately after the Stop method. You should wait for a while.
ActiveXPowUpload.Stop();
Boolean ShowAddFilesDialog()
Shows "Add files" dialog. Selected files will be added to the list.
Return value indicates whether the user selected files to add or canceled the dialog (true - files were selected, false - the dialog was canceled).
ActiveXPowUpload.ShowAddFilesDialog();
Boolean ShowAddFolderDialog()
Shows "Add folder" dialog. All files of the selected folder and its subfolders will be added to the list.
You can set the folder that will be preselected in the dialog using the DefaultUploadFolder property.
Return value indicates whether the user selected a folder to add or canceled the dialog (true - a folder was selected, false - the dialog was canceled).
ActiveXPowUpload.ShowAddFolderDialog();
void AddFormItem(name: String, value: String)
Adds a (name, value) pair to the list of text fields that will be sent as text Form items. To prevent possible name duplication the name can’t match the pattern used for naming files, see FileFormItemPattern. The name can't be empty.
See also FormItemCount, FormItem, FormItems, AddFormItem, RemoveFormItem, RemoveAllFormItems.
Name of text Form item. Must be unique. It is similar to the HTML "Name" parameter of a Form item.
Value of text Form item. It is similar to the HTML "Value" parameter of a Form item.
ActiveXPowUpload.AddFormItem("username", "Jdoe");
void RemoveFormItem(key: Variant)
Removes the text field item from the text fields list with the specified key.
See also FormItemCount, FormItem, FormItems, AddFormItem, RemoveFormItem, RemoveAllFormItems.
It may be either a string or an interger. If string, the key is an item name. If interger, the key is 0-based index of the text item.
ActiveXPowUpload.RemoveFormItem("username");
void RemoveAllFormItems()
Removes all items from the text fields list.
See also FormItemCount, FormItem, FormItems, AddFormItem, RemoveFormItem, RemoveAllFormItems.
ActiveXPowUpload.RemoveAllFormItems();
void RemoveFile(index:Long)
Removes file list element, either file or folder.
A number that indicates a 0-based index of a file list element. The value must be greater than or equal to 0 and less than ActiveXPowUpload.FileListItemCount.
ActiveXPowUpload.RemoveFile(0);
void RemoveSelectedFiles()
Method removes selected (highlighted) file list items.
ActiveXPowUpload.RemoveSelectedFiles();
void RemoveAllFiles()
Method removes all file list items.
ActiveXPowUpload.RemoveAllFiles();
void Paste()
Method adds files from clipboard into the list. If the clipboard contains inappropriate data, nothing will be done. Folders are processed recursively.
ActiveXPowUpload.Paste();
String GetServerReply(codepage: Long)
Returns server reply as a string. It’s everything that server sends in response to upload, normally an html page. The component may detect page encoding automatically most of the time (pass 0 as parameter to use that feature). If automatic detection fails, you may specify the correct codepage in parameter. For example, code page number 65001 is for UTF-8 encoding. See msdn for the complete list of allowed code pages: Code Page Identifiers.
Code page of the server response. Use 0 for autodetection.
window.alert(ActiveXPowUpload.GetServerReply(0));
Long GetServerStatusCode ()
HTTP status code of the server response. 200 in most cases means success, 500 - internal error. You can find most HTTP status codes with short descriptions at the w3.org website.
See also GetServerStatusText.
window.alert(ActiveXPowUpload.GetServerStatusCode());
String GetServerStatusText()
A short description of the HTTP status code, a reason phrase. For code 200 it is usually "OK". You can find most HTTP status codes with short descriptions at the w3.org website.
See also GetServerStatusCode.
window.alert(ActiveXPowUpload.GetServerStatusText());
void ShowProgressWindow()
Shows upload progress window.
See also HideProgressWindow.
ActiveXPowUpload.ShowProgressWindow();
void HideProgressWindow()
Hides upload progress window.
See also ShowProgressWindow.
ActiveXPowUpload.HideProgressWindow();
Boolean ShowSelectDownloadFolderDialog()
Shows a select download folder dialog. A user selects a folder where downloaded files will be saved. The folder must exist.
Use the DownloadFolder property to determine the selected folder.
You can set the folder that will be preselected in the dialog using the DefaultDownloadFolder property.
Return value indicates whether the user selected the download folder or canceled the dialog (true - the download folder was selected, false - the dialog was canceled).
void Download()
Starts download process.
ActiveXPowUpload traverses a number of download states while performing download. The state determines what you can do with the control, what methods you can invoke, what properties you can change.
void StopDownload()
Cancels download process.
Variant GetDownloadItem(Index: Variant)
Returns an object representing a download file. The index may be either a number or a string. If it is a number, it is a 0-based index of the download file in the range [0, DownloadFileCount). If it is a string, it is URL of the download file. When there is no item corresponding to the index specified (incorrect index), a null value is returned. See examples section.
The prefered way to get a reference to a DownloadItem object is using a numerical index, that is more effiecient, then refering by URL.
It may be other a number or a string, other types are not allowed. A number indicates a 0-based index of the download file. The value must be greater than or equal to 0 and less than ActiveXPowUpload.DownloadFileCount
.
When the index is a string, it is interpreted as URL of the download item.
<script language="jscript"> var item = ActiveXPowUpload.GetDownloadItem(0); // Get item by position; item = ActiveXPowUpload.GetDownloadItem("http://myserver.com/path/file.txt"); // Get item by its URL; var index = "0"; item = ActiveXPowUpload.GetDownloadItem(parseInt(index)); // Use this to convert a string into a number item = ActiveXPowUpload.GetItem("http://myserver.com/url/not/in/the/list"); // here file == null /* URL must be well-formed, otherwise you'll get exception, as in this case: */ item = ActiveXPowUpload.GetItem("http://incorrect url!"); </script>
long AddDownloadFile(URL: String, RelPath: StringOpt, FileName: StringOpt, Size: VariantOpt)
Adds a URL to download list.
URL specifies the file to download. Relative URls are supported, but the URL may not be blank or resolve to a blank URL.
A full file name of the downloaded file consists of three components: a Download Folder, a Relative Path, and a File Name. The File Name can be specified explicitly through the FileName parameter or it will be generated based on the value extracted from the URL.
For example, let's
The full file name will be "C:\dir1\dir2\dir3\dir4\file.ext".
It's not necessary the Download Folder to be set before you start adding files. The Download Folder can be changed after files added.
The RelPath parameter undergos changes. Components consisting of a single dot are removed from the path. Parent references are handled inside the path (double dot component is removed with the preceding path component), but references to the parent folders outside the path are not allowed. Path may not contain empty components. Path may not start with a backslash.
For example, the path ".\dir1\dir2\..\dir3\dir4\." becomes "dir1\dir3\dir4". The path "dir1\..\..\dir2\" is illegal because it references to the parent folder outside. The path "dir1\\dir2" is illegal because it contains empty dir name. The path "\dir1\dir2\" is illegal because it starts with a backslash.
Empty path means the downloaded file will be saved in the Download Folder directly. A single dot (".") means the same.
After processing Relative Path becomes the value of the RelPath property.
The FileName is an optional parameter. By default it is empty string. If the FileName is not an empty string, that name will be used to save the download file. If the FileName is an empty string, the file name will be generated based on the value extracted from the URL.
If you specify the file name explicitly, make sure that different URLs will be saved in different files.
Size - optional parameter specifying download file size. If it is not specified, file size is not defined. Actual server file size will be determined when the file will be started download. Server does not always tell the size of the file. Setting the Size parameter helps to calculate download progress when server does not tell the size of the file. The Size parameter must contain not negative integer less than or equal to 2^31 - 1 = 2147483641 = 2 Gb - 1.
A uniform resource locator of the file to download. Supports http and https protocols.
A relative path where the downloaded file will be saved. It must be a folder path, not a file path. Optional parameter.
A file name under which the downloaded file will be saved. Optional parameter.
Download file size. Optional parameter.
Index of the added file.
ActiveXPowUpload.AddDownloadFile("http://www.server.com/dir1/file.ext", "dir", "myname.ext", 1000); ActiveXPowUpload.AddDownloadFile("http://www.server.com/dir1/file.ext", "dir", "", 1000); // here the FileName parameter is omitted ActiveXPowUpload.AddDownloadFile("http://www.server.com/dir1/file.ext", "dir"); // here the Size and FileName parameters are omitted
void RemoveDownloadFile(Index: Long)
Removes the file with the index Index from the list of download files. The Index must be from 0 to DownloadFileCount-1.
An index of the file in the download file list to remove.
void RemoveSelectedDownloadFiles()
Removes all selected items from the list of download files.
void RemoveAllDownloadFiles()
Removes all files from the list of download files.