Source Redirect After Uploading Multiple Documents

There are times where you want to control how the page flow works during and after the document upload process.  The simplest path that this takes is:

  • from a view in the Document Library, clicking on the Upload button
  • which takes you to _layouts/Upload.aspx where you specify the document you want to upload
  • then to the EditForm.aspx to enter the metadata for the document
  • then back to the Document Library view you started on

The way SharePoint “knows” which page to return you to is the Source Query String Parameter.  In the case above, the Source will be the Document Library view you started from, perhaps something like this (note that certain characters are encoded):

Source=http%3A%2F%2Fservername%sitename%libname%2FForms%2FAllItems%2Easpx

You might want to place links elsewhere in your site which takes the user to the document upload page without having to visit the Document Library itself or expose the toolbar on a List View Web Part. To do this, you can simply place a link like this anywhere you want it (carriage returns added for easier reading):

http://servername/sitename/_layouts/Upload.aspx
?List=%7B44C0ABF5%2D0F8E%2D419E%2DAF50%2D952AEDA989FE%7D
&Source=http%3A%2F%2Fservername%2Fsitename%2Fdefault.aspx

If you want to take the user directly to the multiple documents upload page, all you need to do is add this parameter to the Query String: MultipleUpload=1, like this:

http://servername/sitename/_layouts/Upload.aspx
?List=%7B44C0ABF5%2D0F8E%2D419E%2DAF50%2D952AEDA989FE%7D
&Source=http%3A%2F%2Fservername%2Fsitename%2Fdefault.aspx
&MultipleUpload=1

There’s one bugaboo in this: the Source needs to be an absolute URL, not a relative one. If you specify a relative URL, you will be taken to the right page, but the multiple document upload page won’t function. When you click on the OK button, nothing will happen.

So this:

&Source=http%3A%2F%2Fservername%2Fsitename%2Fdefault.aspx

is good, and this:

&Source=%2Fsitename%2Fdefault.aspx

is bad.

As I’ve posted before, you can pass additional parameters with the Source by including them in the URL like this:

http://servername/sitename/_layouts/Upload.aspx
?List=%7B44C0ABF5%2D0F8E%2D419E%2DAF50%2D952AEDA989FE%7D
&MultipleUpload=1
&Source=http%3A%2F%2Fservername%2Fsitename%2Fdefault.aspx?ProjectID=200&SubProject=345

Note that to do this, you need to have your Source Query String parameter in the last position in the URL.  This is required due to the ? you need to pass the additional parameters on the Source redirect URL.

Similar Posts

4 Comments

  1. brilliant! i was having issues with my redirects producing a 404 error. adding the ascii equivalent to the url fixed the issue

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.