I've received a couple of requests lately about how to implement drag-and-drop multiple file uploads in Internet Explorer from within managed code. Fortunately for me, someone else has already taken the liberty of writing an article on the subject at large: Host Secure, Lightweight Client-Side Controls in Microsoft Internet Explorer. Just a couple of tweaks and it'll be accepting files via drag and drop too.

In MultiUploadCtrl.cs, we need to enable drag and drop processing in the user control. Setting AllowDrop=True handles that in one swoop, now all that's left is the plumbing to handle the dropped files. For the events, DragEnter and DragDrop, the following should work well:

private void MultiUploadCtrl_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
 
if (e.Data.GetDataPresent("FileDrop"))
   
e.Effect = DragDropEffects.Copy;
 
else
   
e.Effect = DragDropEffects.None;
}

private void MultiUploadCtrl_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
 
new FileIOPermission(PermissionState.Unrestricted).Assert();
 
foreach (string fileListItem in (e.Data.GetData("FileDrop") as string[]))
 
{
   
if (!fileTable.Contains(fileListItem))
   
{
     
AddFile(fileListItem);
   
}
 
}
 
CodeAccessPermission.RevertAssert();
 
UpdateFileSizeDescription();
}