Using multi-upload control (STSUpld.UploadCtl) in Custom SharePoint Page

Using multi-upload control (STSUpld.UploadCtl) in Custom SharePoint Page


UploadCtl is an ActiveX control shipped with MSOffice 2003 which allows multiple documents to be uploaded from an external application to a document library on a site in Microsoft Windows SharePoint Services.
So, in this way we can upload multiple files at a time in any Document Library.

Now, the Question is can we use the same functionality in our custom pages. The answer is yes, we can use this feature. I have still unable to use this Active X control in ASP.Net application. But I have used it in SharePoint Application.

if we look at the URL of above Page(Image), it is like


Upload.aspx page uses these following querystring to upload the file. If we decode it we find that

List= ListID
Root Folder= /sites/SC1/S1/Pages
http://teseserver/sites/SC1/S1/Pages/Forms/AllItems.aspx //Redirect the page here after upload
MultipleUpload=1 //It shows we need to open Multiple Upload Page

So, we can redirect the page with those above QueryStrings.

The Design Page:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
    <head id="Head1" runat="server">
<title>Multi Upload</title>
<form id="form1" runat="server">
<object id="objMultiUpload" name="objMultiUpload" classid="CLSID:07B06095-5687-4d13-9E32-12B4259C9813" width="100%" ></object>
<asp:Button ID="btnMultiFile" runat="server" Text="Upload all" OnClick="btnMultiFile_Click"  />
<input type="hidden" name="Confirmation-URL" value="<%= _redirectURL %>" />
<input type="hidden" id="PostURL" name="PostURL" />

The CLSID:07B06095-5687-4d13-9E32-12B4259C9813 is the CID of the Upload ActiveX Control.  


Coding Page:

The attachment process will go through two steps

  1. Upload the file in Server’s Temp Directory
  2. Upload  the files from Temp to Document Library
  3. Delete the temp File

   if (Request.Files.Count > 0)
HttpPostedFile File = null;
        for (int i = 0; i < Request.Files.Count; i++)
File = Request.Files[i];
f (dtAttachFile == null)
if (File != null && File.FileName != String.Empty && File.ContentLength > 0)
drAttachFile = dtAttachFile.NewRow();
string _tempFolder = Environment.GetEnvironmentVariable("TEMP");
string _fileTime = DateTime.Now.ToFileTime().ToString();
string _fileName = System.IO.Path.GetFileName(File.FileName);
string _newfilePath = _fileTime + "~" + _fileName;
string _filepath = _tempFolder + "\\" + _newfilePath;
                drAttachFile["FileName"] = _fileName;
drAttachFile["FilePath"] = _filepath;
        SPList List = this._myTeamSite.Lists[Request.QueryString["List"]];
SPListItem newItem = List.Items.Add();
foreach (DataRow drAttachFile in dtAttachFile.Rows)
fileName = drAttachFile["Filename"].ToString();
strFilepath = drAttachFile["FilePath"].ToString();
StreamReader sr = new StreamReader(strFilepath);        
Stream fStream = sr.BaseStream;
contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
newItem.Attachments.Add(fileName, contents);
this._myTeamSite .AllowUnsafeUpdates = true;
this._myTeamSite .AllowUnsafeUpdates = false;


Download the source code:

For multiple file upload you can look at:

Jayant Sharma

Leave a Comment
  • Please add 2 and 6 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
  • good one.

  • I am able to make it work in 2007...

    But its not working with SharePoint 2010 (Office 2010 STSUPLD.dll) drag and drop control.

    Please let me know if you have any soln.

  • Nice article!

  • I cannot get this to work in 2010 either

  • To control (Office 2010 STSUPLD.dll)  to work properly with SharePoint 2010, add on page element

    <input type="hidden" name="destination" id="destination" value="/Documents" />

    where for  value specify relative Document Library Url

  • Maheshkumar S Tiwari edited Original. Comment: Added tags

Page 1 of 1 (6 items)