UploadCtl Control
An UploadCtl control allows multiple documents to be uploaded from an external application to a document library on a site in Microsoft Windows SharePoint Services. When a user clicks Upload Multiple Files... on Upload.aspx, the page for uploading documents, an <OBJECT> tag for the control is created on the page as follows:
<OBJECT id=idUploadCtl name=idUploadCtl
CLASSID=CLSID:07B06095-5687-4d13-9E32-12B4259C9813
WIDTH='100%' HEIGHT='350px'></OBJECT>
Note The CLSID used in this tag is the GUID that uniquely identifies the ActiveX control that is installed with Microsoft Office 2003. To implement a custom control for uploading documents, specify a different GUID.
When Office 2003 is installed on the client computer, this control is defined in the STSUPLD.DLL file, a dynamic-link library (DLL) that is installed on the client during Office 2003 setup in the Local_Drive:\Program Files\Microsoft Office\OFFICE11 directory.
MultipleUpload Method
Uploads multiple documents to the document library.
Syntax
expression**.MultipleUpload**()
expression | An expression that returns an UploadCtl object. |
SetTreeViewColor Method
Sets the background color of the tree view used to display the local folders from which to select documents for uploading.
Syntax
expression**.SetTreeViewColor**(newVal)
expression | An expression that returns an UploadCtl object. |
newVal | A string of the form #aabbcc, where the characters are hexadecimal values in the order BGR and represent the color. |
Example
The following example steps through the process of adding an UploadCtl control to an .aspx page for uploading multiple documents to the Shared Documents folder of a specified site. The example adds a hidden UploadCtl control within the page that is displayed when a link is clicked.
The .aspx file, in this example WebForm1.aspx, must be located in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS directory, and is opened through the URL http://Server_Name/_layouts/WebForm1.aspx.
Add a page directive that registers the Microsoft.SharePoint.WebControls namespace:
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
Note You can obtain the PublicKeyToken value for the current Microsoft Windows SharePoint Services deployment from the default.aspx file in the Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LCID(1033 in English)\STS folder, or from information provided for the Microsoft.SharePoint assembly at Local_Drive:\WINDOWS|WINNT\assembly in Windows Explorer.
Add a LINK element in the HEAD section to apply Windows SharePoint Services styles that are defined in ows.css:
<LINK REL="stylesheet" TYPE="text/css" HREF="/_layouts/1033/styles/ows.css">
Add a script block to the HEAD that includes 2 methods. One method sets the background color for the tree view and displays the UploadCtl on the page. The other method uploads documents that are selected in the control.
<SCRIPT LANGUAGE="javascript"> function MultipleUploadView() { document.all.idUploadCtl.SetTreeViewColor("#FF0000"); document.all("idMultipleView").style.display="inline"; } function DocumentUpload() { document.all.idUploadCtl.MultipleUpload(); } </SCRIPT>
Add a form within the BODY section of the .aspx page:
<FORM NAME="frmUpload" METHOD="post" ACTION="WebForm1.aspx?RootFolder=&Source=http%3A%2F%2FServer_Name%2FShared%2520Documents%2FForms%2FAllItems%2Easpx">
In order to upload documents and thereby modify data within a SharePoint site, a FormDigest server control must be included in the form:
<SharePoint:FormDigest />
Include INPUT elements that specify the required parameters of the post:
<INPUT TYPE="hidden" NAME="Cmd" VALUE="Save"> <INPUT TYPE="hidden" NAME="NextUsing" VALUE="http://Server_Name/Shared%20Documents/Forms/AllItems.aspx"> <INPUT TYPE="hidden" VALUE="New"> <INPUT TYPE="hidden" NAME="putopts" VALUE="true"> <INPUT TYPE="hidden" NAME="destination" VALUE="http://Server_Name/Shared Documents"> <INPUT TYPE="hidden" NAME="Confirmation-URL" VALUE="http://Server_Name/Shared%20Documents/Forms/AllItems.aspx"> <INPUT TYPE="hidden" NAME="PostURL" VALUE="http%3a%2f%2fServer_Name/_vti_bin/shtml.dll/_layouts%2fWebForm1%2easpx" /> <INPUT TYPE="hidden" NAME="VTI-GROUP" VALUE="0">
To complete the form, add a link for calling the MultipleUploadView method and displaying the contents of a DIV section, which includes the OBJECT tag that creates the control on the page:
<P CLASS="ms-toolbar"> <A HREF="javascript:MultipleUploadView()" TARGET="_self">Upload Multiple Files</A> </P> <DIV ID=idMultipleView style='display:none'> <P CLASS="ms-toolbar"> <A HREF="javascript:DocumentUpload()" TARGET="_self">Save and Close</A> </P> <OBJECT id=idUploadCtl name=idUploadCtl CLASSID=CLSID:07B06095-5687-4d13-9E32-12B4259C9813 WIDTH='100%' HEIGHT='350px'> </OBJECT> </DIV> </FORM>